MCPcopy Create free account
hub / github.com/microsoft/TypeChat / main

Function main

python/examples/healthData/demo.py:20–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18"""
19
20async def main():
21 env_vals = dotenv_values()
22 model = create_language_model(env_vals)
23 validator = TypeChatValidator(health.HealthDataResponse)
24 translator = TranslatorWithHistory(
25 model, validator, health.HealthDataResponse, additional_agent_instructions=health_instructions
26 )
27
28 async def request_handler(message: str):
29 result = await translator.translate(message)
30 if isinstance(result, Failure):
31 print(result.message)
32 else:
33 result = result.value
34 print(json.dumps(result, indent=2))
35
36 agent_message = result.get("message", "None")
37 not_translated = result.get("notTranslated", None)
38
39 if agent_message:
40 print(f"\n📝: {agent_message}")
41
42 if not_translated:
43 print(f"\n🤔: I did not understand\n {not_translated}")
44
45
46 file_path = sys.argv[1] if len(sys.argv) == 2 else None
47 await process_requests("💉💊🤧> ", file_path, request_handler)
48
49
50if __name__ == "__main__":

Callers 1

demo.pyFile · 0.70

Calls 4

create_language_modelFunction · 0.90
TypeChatValidatorClass · 0.90
process_requestsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…