mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 20:28:23 +00:00
simple example
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import openai
|
||||
|
||||
client = openai.OpenAI(
|
||||
api_key=os.environ["CASHU_TOKEN"],
|
||||
base_url=os.environ.get("ROUTSTR_API_URL", "https://api.routstr.com/v1"),
|
||||
)
|
||||
history: list = []
|
||||
|
||||
|
||||
def chat():
|
||||
while True:
|
||||
message = input("\nYou: ")
|
||||
|
||||
for chunk in client.chat.completions.create(
|
||||
model=os.environ.get(
|
||||
"MODEL", "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8"
|
||||
),
|
||||
messages=history + [{"role": "user", "content": message}],
|
||||
stream=True,
|
||||
):
|
||||
if len(chunk.choices) > 0:
|
||||
print(chunk.choices[0].delta.content, end="", flush=True)
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
chat()
|
||||
Reference in New Issue
Block a user