MCPcopy
hub / github.com/lm-sys/FastChat / get_api_provider_stream_iter

Function get_api_provider_stream_iter

fastchat/serve/api_provider.py:16–88  ·  view source on GitHub ↗
(
    conv,
    model_name,
    model_api_dict,
    temperature,
    top_p,
    max_new_tokens,
)

Source from the content-addressed store, hash-verified

14
15
16def get_api_provider_stream_iter(
17 conv,
18 model_name,
19 model_api_dict,
20 temperature,
21 top_p,
22 max_new_tokens,
23):
24 if model_api_dict["api_type"] == "openai":
25 prompt = conv.to_openai_api_messages()
26 stream_iter = openai_api_stream_iter(
27 model_api_dict["model_name"],
28 prompt,
29 temperature,
30 top_p,
31 max_new_tokens,
32 api_base=model_api_dict["api_base"],
33 api_key=model_api_dict["api_key"],
34 )
35 elif model_api_dict["api_type"] == "anthropic":
36 prompt = conv.get_prompt()
37 stream_iter = anthropic_api_stream_iter(
38 model_name, prompt, temperature, top_p, max_new_tokens
39 )
40 elif model_api_dict["api_type"] == "gemini":
41 stream_iter = gemini_api_stream_iter(
42 model_api_dict["model_name"],
43 conv,
44 temperature,
45 top_p,
46 max_new_tokens,
47 api_key=model_api_dict["api_key"],
48 )
49 elif model_api_dict["api_type"] == "bard":
50 prompt = conv.to_openai_api_messages()
51 stream_iter = bard_api_stream_iter(
52 model_api_dict["model_name"],
53 prompt,
54 temperature,
55 top_p,
56 api_key=model_api_dict["api_key"],
57 )
58 elif model_api_dict["api_type"] == "mistral":
59 prompt = conv.to_openai_api_messages()
60 stream_iter = mistral_api_stream_iter(
61 model_name, prompt, temperature, top_p, max_new_tokens
62 )
63 elif model_api_dict["api_type"] == "nvidia":
64 prompt = conv.to_openai_api_messages()
65 stream_iter = nvidia_api_stream_iter(
66 model_name,
67 prompt,
68 temperature,
69 top_p,
70 max_new_tokens,
71 model_api_dict["api_base"],
72 )
73 elif model_api_dict["api_type"] == "ai2":

Callers 1

bot_responseFunction · 0.90

Calls 9

openai_api_stream_iterFunction · 0.85
gemini_api_stream_iterFunction · 0.85
bard_api_stream_iterFunction · 0.85
mistral_api_stream_iterFunction · 0.85
nvidia_api_stream_iterFunction · 0.85
ai2_api_stream_iterFunction · 0.85
get_promptMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…