yym68686 commited on
Commit
f3fce0a
·
1 Parent(s): 163e912

Fix the bug where claude stream is not defined.

Browse files
Files changed (1) hide show
  1. request.py +3 -6
request.py CHANGED
@@ -40,8 +40,7 @@ async def get_gemini_payload(request, engine, provider):
40
  'Content-Type': 'application/json'
41
  }
42
  model = provider['model'][request.model]
43
- if request.stream:
44
- gemini_stream = "streamGenerateContent"
45
  url = provider['base_url']
46
  if url.endswith("v1beta"):
47
  url = "https://generativelanguage.googleapis.com/v1beta/models/{model}:{stream}?key={api_key}".format(model=model, stream=gemini_stream, api_key=provider['api'])
@@ -232,8 +231,7 @@ async def get_vertex_gemini_payload(request, engine, provider):
232
  if provider.get("project_id"):
233
  project_id = provider.get("project_id")
234
 
235
- if request.stream:
236
- gemini_stream = "streamGenerateContent"
237
  model = provider['model'][request.model]
238
  location = gem
239
  url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/google/models/{MODEL_ID}:{stream}".format(LOCATION=location.next(), PROJECT_ID=project_id, MODEL_ID=model, stream=gemini_stream)
@@ -381,8 +379,7 @@ async def get_vertex_claude_payload(request, engine, provider):
381
  elif "claude-3-haiku" in model:
382
  location = c3h
383
 
384
- if request.stream:
385
- claude_stream = "streamRawPredict"
386
  url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/anthropic/models/{MODEL}:{stream}".format(LOCATION=location.next(), PROJECT_ID=project_id, MODEL=model, stream=claude_stream)
387
 
388
  messages = []
 
40
  'Content-Type': 'application/json'
41
  }
42
  model = provider['model'][request.model]
43
+ gemini_stream = "streamGenerateContent"
 
44
  url = provider['base_url']
45
  if url.endswith("v1beta"):
46
  url = "https://generativelanguage.googleapis.com/v1beta/models/{model}:{stream}?key={api_key}".format(model=model, stream=gemini_stream, api_key=provider['api'])
 
231
  if provider.get("project_id"):
232
  project_id = provider.get("project_id")
233
 
234
+ gemini_stream = "streamGenerateContent"
 
235
  model = provider['model'][request.model]
236
  location = gem
237
  url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/google/models/{MODEL_ID}:{stream}".format(LOCATION=location.next(), PROJECT_ID=project_id, MODEL_ID=model, stream=gemini_stream)
 
379
  elif "claude-3-haiku" in model:
380
  location = c3h
381
 
382
+ claude_stream = "streamRawPredict"
 
383
  url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/anthropic/models/{MODEL}:{stream}".format(LOCATION=location.next(), PROJECT_ID=project_id, MODEL=model, stream=claude_stream)
384
 
385
  messages = []