MCPcopy
hub / github.com/openai/gpt-oss / run

Function run

examples/streamlit/streamlit_chat.py:105–297  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

103
104
105def run(container):
106 tools = []
107 if use_functions:
108 tools.append(
109 {
110 "type": "function",
111 "name": function_name,
112 "description": function_description,
113 "parameters": json.loads(function_parameters),
114 }
115 )
116 # Add browser_search tool if checkbox is checked
117 if use_browser_search:
118 tools.append({"type": "browser_search"})
119 if use_code_interpreter:
120 tools.append({"type": "code_interpreter"})
121 response = requests.post(
122 URL,
123 json={
124 "input": st.session_state.messages,
125 "stream": True,
126 "instructions": instructions,
127 "reasoning": {"effort": effort},
128 "metadata": {"__debug": debug_mode},
129 "tools": tools,
130 "temperature": temperature,
131 "max_output_tokens": max_output_tokens,
132 },
133 stream=True,
134 )
135
136 text_delta = ""
137 code_interpreter_sessions: dict[str, dict] = {}
138
139 _current_output_index = 0
140 for line in response.iter_lines(decode_unicode=True):
141 if not line or not line.startswith("data:"):
142 continue
143 data_str = line[len("data:") :].strip()
144 if not data_str:
145 continue
146 try:
147 data = json.loads(data_str)
148 except Exception:
149 continue
150
151 event_type = data.get("type", "")
152 output_index = data.get("output_index", 0)
153 if event_type == "response.output_item.added":
154 _current_output_index = output_index
155 output_type = data.get("item", {}).get("type", "message")
156 if output_type == "message":
157 output = container.chat_message("assistant")
158 placeholder = output.empty()
159 elif output_type == "reasoning":
160 output = container.chat_message("reasoning", avatar="🤔")
161 placeholder = output.empty()
162 elif output_type == "web_search_call":

Callers 3

trigger_fake_toolFunction · 0.70
streamlit_chat.pyFile · 0.70
index.tsFile · 0.50

Calls 3

startswithMethod · 0.80
getMethod · 0.80
extendMethod · 0.80

Tested by

no test coverage detected