()
| 18 | """ |
| 19 | |
| 20 | async 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 | |
| 50 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…