|
| 1 | +# Copyright © 2023- Frello Technology Private Limited |
| 2 | + |
| 3 | +from tuneapi import ta, tt |
| 4 | + |
| 5 | +import asyncio |
| 6 | +from pydantic import BaseModel |
| 7 | + |
| 8 | +# fmt: off |
| 9 | +print("[BLOCKING] [Anthropic]", ta.Anthropic().chat("2 + 2 =", max_tokens=10)) |
| 10 | +print("[BLOCKING] [Openai]", ta.Openai().chat("2 + 2 =", max_tokens=10)) |
| 11 | +print("[BLOCKING] [Gemini]", ta.Gemini().chat("2 + 2 =", max_tokens=10)) |
| 12 | +print("[BLOCKING] [Mistral]", ta.Mistral().chat("2 + 2 =", max_tokens=10)) |
| 13 | +print("[BLOCKING] [Groq]", ta.Groq().chat("2 + 2 =", max_tokens=10)) |
| 14 | +print("[BLOCKING] [TuneAI]", ta.TuneModel("meta/llama-3.1-8b-instruct").chat("2 + 2 =", max_tokens=10)) |
| 15 | +# fmt: on |
| 16 | + |
| 17 | + |
| 18 | +class Result(BaseModel): |
| 19 | + result: int |
| 20 | + |
| 21 | + |
| 22 | +# fmt: off |
| 23 | +print("[BLOCKING] [STRUCTURE] [Openai]", ta.Openai().chat(tt.Thread(tt.human("2 + 2 ="), schema=Result), max_tokens=10).result) |
| 24 | +print("[BLOCKING] [STRUCTURE] [Gemini]", ta.Gemini().chat(tt.Thread(tt.human("2 + 2 ="), schema=Result), max_tokens=10).result) |
| 25 | +# fmt: on |
| 26 | + |
| 27 | + |
| 28 | +async def main(): |
| 29 | + # fmt: off |
| 30 | + print("[ASYNC] [Anthropic]", await ta.Anthropic().chat_async("2 + 2 =", max_tokens=10)) |
| 31 | + print("[ASYNC] [Openai]", await ta.Openai().chat_async("2 + 2 =", max_tokens=10)) |
| 32 | + print("[ASYNC] [Gemini]", await ta.Gemini().chat_async("2 + 2 =", max_tokens=10)) |
| 33 | + print("[ASYNC] [Mistral]", await ta.Mistral().chat_async("2 + 2 =", max_tokens=10)) |
| 34 | + print("[ASYNC] [Groq]", await ta.Groq().chat_async("2 + 2 =", max_tokens=10)) |
| 35 | + print("[ASYNC] [TuneAI]", await ta.TuneModel("meta/llama-3.1-8b-instruct").chat_async("2 + 2 =", max_tokens=10)) |
| 36 | + # fmt: on |
| 37 | + |
| 38 | + |
| 39 | +asyncio.run(main()) |
0 commit comments