tyagonzales66 commited on
Commit
0464135
·
verified ·
1 Parent(s): 2fd26d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
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=False # Désactiver le streaming pour simplifier
93
  )
94
- continuation_text = completion.choices[0].message.content.strip()
 
 
 
 
 
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: