diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index d31587e33c..b8a4a5a0de 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -301,7 +301,7 @@ class Base(ABC): "role": "assistant", "tool_calls": [ { - "index": tool_call.index, + "index": getattr(tool_call, "index", None), "id": tool_call.id, "function": { "name": tool_call.function.name, @@ -325,18 +325,20 @@ class Base(ABC): one assistant message containing all tool_calls, followed by one tool message per call. results: list of (tool_call, name, args, result, error) """ - hist.append({ - "role": "assistant", - "tool_calls": [ - { - "index": tc.index, - "id": tc.id, - "function": {"name": tc.function.name, "arguments": tc.function.arguments}, - "type": "function", - } - for tc, _, _, _, _ in results - ], - }) + hist.append( + { + "role": "assistant", + "tool_calls": [ + { + "index": getattr(tc, "index", None), + "id": tc.id, + "function": {"name": tc.function.name, "arguments": tc.function.arguments}, + "type": "function", + } + for tc, _, _, _, _ in results + ], + } + ) for tc, _, _, result, err in results: if err: content = str(err) @@ -1474,7 +1476,7 @@ class LiteLLMBase(ABC): "role": "assistant", "tool_calls": [ { - "index": tool_call.index, + "index": getattr(tool_call, "index", None), "id": tool_call.id, "function": { "name": tool_call.function.name, @@ -1504,7 +1506,7 @@ class LiteLLMBase(ABC): "role": "assistant", "tool_calls": [ { - "index": tc.index, + "index": getattr(tc, "index", None), "id": tc.id, "function": {"name": tc.function.name, "arguments": tc.function.arguments}, "type": "function", @@ -1850,17 +1852,19 @@ class LiteLLMBase(ABC): completion_args["extra_headers"] = extra_headers return completion_args + class RAGconChat(Base): """ RAGcon Chat Provider - routes through LiteLLM proxy - + All model types are handled through a unified LiteLLM endpoint. Default Base URL: https://connect.ragcon.com/v1 """ + _FACTORY_NAME = "RAGcon" - + def __init__(self, key, model_name, base_url=None, **kwargs): if not base_url: base_url = "https://connect.ragcon.com/v1" - + super().__init__(key, model_name, base_url, **kwargs)