Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,10 +27,7 @@ try:
|
|
| 27 |
client = OpenAI(
|
| 28 |
base_url=NVIDIA_API_URL,
|
| 29 |
api_key=NVIDIA_API_KEY,
|
| 30 |
-
http_client=httpx.Client(
|
| 31 |
-
proxies=None, # Explicitement désactiver les proxies
|
| 32 |
-
timeout=30.0
|
| 33 |
-
)
|
| 34 |
)
|
| 35 |
print("Successfully initialized NVIDIA API client")
|
| 36 |
except Exception as e:
|
|
@@ -89,9 +86,14 @@ async def webhook(request: Request) -> Dict[str, Any]:
|
|
| 89 |
temperature=0.5,
|
| 90 |
top_p=1,
|
| 91 |
max_tokens=100,
|
| 92 |
-
stream=
|
| 93 |
)
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
print(f"NVIDIA API response: {continuation_text}")
|
| 96 |
|
| 97 |
if not continuation_text:
|
|
|
|
| 27 |
client = OpenAI(
|
| 28 |
base_url=NVIDIA_API_URL,
|
| 29 |
api_key=NVIDIA_API_KEY,
|
| 30 |
+
http_client=httpx.Client()
|
|
|
|
|
|
|
|
|
|
| 31 |
)
|
| 32 |
print("Successfully initialized NVIDIA API client")
|
| 33 |
except Exception as e:
|
|
|
|
| 86 |
temperature=0.5,
|
| 87 |
top_p=1,
|
| 88 |
max_tokens=100,
|
| 89 |
+
stream=True
|
| 90 |
)
|
| 91 |
+
# Collecter les morceaux de texte généré
|
| 92 |
+
continuation_text = ""
|
| 93 |
+
for chunk in completion:
|
| 94 |
+
if chunk.choices[0].delta.content is not None:
|
| 95 |
+
continuation_text += chunk.choices[0].delta.content
|
| 96 |
+
continuation_text = continuation_text.strip()
|
| 97 |
print(f"NVIDIA API response: {continuation_text}")
|
| 98 |
|
| 99 |
if not continuation_text:
|