MCPcopy
hub / github.com/langroid/langroid / achat

Method achat

langroid/language_models/mock_lm.py:93–107  ·  view source on GitHub ↗

Mock chat function for testing

(
        self,
        messages: Union[str, List[lm.LLMMessage]],
        max_tokens: int = 200,
        tools: Optional[List[OpenAIToolSpec]] = None,
        tool_choice: ToolChoiceTypes | Dict[str, str | Dict[str, str]] = "auto",
        functions: Optional[List[lm.LLMFunctionSpec]] = None,
        function_call: str | Dict[str, str] = "auto",
        response_format: Optional[OpenAIJsonSchemaSpec] = None,
    )

Source from the content-addressed store, hash-verified

91 return self._response(last_msg)
92
93 async def achat(
94 self,
95 messages: Union[str, List[lm.LLMMessage]],
96 max_tokens: int = 200,
97 tools: Optional[List[OpenAIToolSpec]] = None,
98 tool_choice: ToolChoiceTypes | Dict[str, str | Dict[str, str]] = "auto",
99 functions: Optional[List[lm.LLMFunctionSpec]] = None,
100 function_call: str | Dict[str, str] = "auto",
101 response_format: Optional[OpenAIJsonSchemaSpec] = None,
102 ) -> lm.LLMResponse:
103 """
104 Mock chat function for testing
105 """
106 last_msg = messages[-1].content if isinstance(messages, list) else messages
107 return await self._response_async(last_msg)
108
109 def generate(self, prompt: str, max_tokens: int = 200) -> lm.LLMResponse:
110 """

Callers 3

test_azure_openai_asyncFunction · 0.45
make_achat_requestMethod · 0.45

Calls 1

_response_asyncMethod · 0.95

Tested by 2

test_azure_openai_asyncFunction · 0.36
make_achat_requestMethod · 0.36