mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-09 11:04:36 +00:00
29 lines
708 B
Python
29 lines
708 B
Python
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()
|