Patrefans
echohive42 from patreon
echohive42 patreon

Code Files for Streaming responses with GPT Function Calling. Structured data with GPT 4 and Gpt 3.5 turbo video

🕑 Added 2023-07-04 10:18:43 +0000 UTC
Code Files for Streaming responses with GPT Function Calling. Structured data with GPT 4 and Gpt 3.5 turbo video

Comments

Echo Hive

I responded under your original comment. You can use try, except for json.load and when that fails you can just get the regular response and give that back as feedback. That should be fine. Or you can try to parse it with string method or with regex

xiaoyang feng

There's always something wrong with that one:~program_criticism_feedback = json.loads(clean_responses)["criticism_feedback"]~

Echo Hive

I give an example of how to do that in gpt-4 scientist

Echo Hive

Yeah, that happens when gpt returns a response which the json can not parse. This happens especially with 3.5. You can try to parse the result using reflex or other regular methods for when this happens.

xiaoyang feng

Traceback (most recent call last): File "/mnt/sda/github/echohive/0802Function_calling/multi_call_maker.py", line 77, in start_maker_process() File "/mnt/sda/github/echohive/0802Function_calling/multi_call_maker.py", line 74, in start_maker_process run_maker_process(user_input, model) File "/mnt/sda/github/echohive/0802Function_calling/multi_call_maker.py", line 10, in run_maker_process criticism_feedback = program_criticism_feedback(user_input,general_outline, model) File "/mnt/sda/github/echohive/0802Function_calling/separate_calls.py", line 132, in program_criticism_feedback program_criticism_feedback = json.loads(clean_responses)["criticism_feedback"] File "/opt/miniconda3/envs/py310_chat/lib/python3.10/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/opt/miniconda3/envs/py310_chat/lib/python3.10/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/opt/miniconda3/envs/py310_chat/lib/python3.10/json/decoder.py", line 353, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 125 (char 124)


More Creators