summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--etc/examples/api.py19
-rw-r--r--etc/examples/ecosia.py (renamed from examples/ecosia.py)0
-rw-r--r--etc/examples/openaichat.py (renamed from examples/openaichat.py)0
-rw-r--r--etc/unittest/integration.py1
4 files changed, 20 insertions, 0 deletions
diff --git a/etc/examples/api.py b/etc/examples/api.py
new file mode 100644
index 00000000..d4d03a77
--- /dev/null
+++ b/etc/examples/api.py
@@ -0,0 +1,19 @@
+import requests
+import json
+url = "http://localhost:1337/v1/chat/completions"
+body = {
+ "model": "",
+ "provider": "MetaAI",
+ "stream": True,
+ "messages": [
+ {"role": "assistant", "content": "What can you do? Who are you?"}
+ ]
+}
+lines = requests.post(url, json=body, stream=True).iter_lines()
+for line in lines:
+ if line.startswith(b"data: "):
+ try:
+ print(json.loads(line[6:]).get("choices", [{"delta": {}}])[0]["delta"].get("content", ""), end="")
+ except json.JSONDecodeError:
+ pass
+print() \ No newline at end of file
diff --git a/examples/ecosia.py b/etc/examples/ecosia.py
index 5a2ae520..5a2ae520 100644
--- a/examples/ecosia.py
+++ b/etc/examples/ecosia.py
diff --git a/examples/openaichat.py b/etc/examples/openaichat.py
index 291daa2c..291daa2c 100644
--- a/examples/openaichat.py
+++ b/etc/examples/openaichat.py
diff --git a/etc/unittest/integration.py b/etc/unittest/integration.py
index 379f36b6..1f7fb000 100644
--- a/etc/unittest/integration.py
+++ b/etc/unittest/integration.py
@@ -19,6 +19,7 @@ class TestProviderIntegration(unittest.TestCase):
self.skipTest("nest_asyncio is not installed")
def test_bing(self):
+ self.skipTest("Not working")
client = Client(provider=Bing)
response = client.chat.completions.create(DEFAULT_MESSAGES, "", response_format={"type": "json_object"})
self.assertIsInstance(response, ChatCompletion)