summaryrefslogtreecommitdiffstats
path: root/testing/test_interference.py
diff options
context:
space:
mode:
authorMIDORIBIN <aquarion123@gmail.com>2023-07-28 12:07:17 +0200
committerMIDORIBIN <aquarion123@gmail.com>2023-08-14 04:46:32 +0200
commitf6ef3cb2237d8c336e915ef77ddbe6f37934c4fd (patch)
treec8bc44917ea03909cf586140f984ff0814bc30ea /testing/test_interference.py
parent~ | small fixes & new pypi version | v-0.0.1.9 (diff)
downloadgpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.gz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.bz2
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.lz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.xz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.zst
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.zip
Diffstat (limited to '')
-rw-r--r--testing/test_interference.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/testing/test_interference.py b/testing/test_interference.py
new file mode 100644
index 00000000..31717ea7
--- /dev/null
+++ b/testing/test_interference.py
@@ -0,0 +1,27 @@
+# type: ignore
+import openai
+
+openai.api_key = ""
+openai.api_base = "http://localhost:1337"
+
+
+def main():
+ chat_completion = openai.ChatCompletion.create(
+ model="gpt-3.5-turbo",
+ messages=[{"role": "user", "content": "write a poem about a tree"}],
+ stream=True,
+ )
+
+ if isinstance(chat_completion, dict):
+ # not stream
+ print(chat_completion.choices[0].message.content)
+ else:
+ # stream
+ for token in chat_completion:
+ content = token["choices"][0]["delta"].get("content")
+ if content != None:
+ print(content, end="", flush=True)
+
+
+if __name__ == "__main__":
+ main()