MCPcopy Index your code
hub / github.com/microsoft/TypeChat / FixedModel

Class FixedModel

python/tests/test_translator.py:11–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 payload: str | list[typechat.PromptSection]
10
11class FixedModel(typechat.TypeChatLanguageModel):
12 responses: Iterator[str]
13 conversation: list[ConvoRecord]
14
15 "A model which responds with one of a series of responses."
16 def __init__(self, responses: list[str]) -> None:
17 super().__init__()
18 self.responses = iter(responses)
19 self.conversation = []
20
21 @override
22 async def complete(self, prompt: str | list[typechat.PromptSection]) -> typechat.Result[str]:
23 # Capture a snapshot because the translator
24 # can choose to pass in the same underlying list.
25 if isinstance(prompt, list):
26 prompt = prompt.copy()
27
28 self.conversation.append({ "kind": "CLIENT REQUEST", "payload": prompt })
29 response = next(self.responses)
30 self.conversation.append({ "kind": "MODEL RESPONSE", "payload": response })
31 return typechat.Success(response)
32
33@dataclass
34class ExampleABC:

Calls

no outgoing calls