Update app.py
Browse files
app.py
CHANGED
|
@@ -32,6 +32,38 @@ def build_message(input_text, history):
|
|
| 32 |
f"Neue Nachricht des Nutzers:\n{input_text}"
|
| 33 |
)
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
def qwen(input_text):
|
| 36 |
client = Client("zai-org/GLM-4.5-Space")
|
| 37 |
result = client.predict(
|
|
|
|
| 32 |
f"Neue Nachricht des Nutzers:\n{input_text}"
|
| 33 |
)
|
| 34 |
|
| 35 |
+
from openai import OpenAI
|
| 36 |
+
def tokenrouter(input_text):
|
| 37 |
+
client = OpenAI(
|
| 38 |
+
base_url='https://api.tokenrouter.com/v1',
|
| 39 |
+
api_key=os.environ.get("HF_TOKEN"),
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
messages = [
|
| 43 |
+
{"role": "system", "content": "You are an intelligent assistant, please reply concisely."},
|
| 44 |
+
{"role": "user", "content": "Hello, what kind of model are you?"},
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
stream = client.chat.completions.create(
|
| 48 |
+
model="qwen/qwen3.8-max",
|
| 49 |
+
messages=messages,
|
| 50 |
+
stream=True,
|
| 51 |
+
stream_options={"include_usage": True},
|
| 52 |
+
extra_body={}
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
content_parts = []
|
| 56 |
+
for chunk in stream:
|
| 57 |
+
if chunk.choices:
|
| 58 |
+
delta = chunk.choices[0].delta
|
| 59 |
+
if delta and delta.content:
|
| 60 |
+
content_parts.append(delta.content)
|
| 61 |
+
|
| 62 |
+
full_content = "".join(content_parts)
|
| 63 |
+
|
| 64 |
+
return full_content
|
| 65 |
+
|
| 66 |
+
|
| 67 |
def qwen(input_text):
|
| 68 |
client = Client("zai-org/GLM-4.5-Space")
|
| 69 |
result = client.predict(
|