emiAi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
emiai-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: emiAi
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for EmiAI API
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests>=2.28
emiai-0.1.0/README.md ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "emiAi"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for EmiAI API"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ dependencies = [
12
+ "requests>=2.28"
13
+ ]
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["src"]
17
+
18
+ [tool.setuptools]
19
+ package-dir = {"" = "src"}
emiai-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .client import EmiAI
2
+
3
+ __all__ = ["EmiAI"]
@@ -0,0 +1,48 @@
1
+ import requests
2
+
3
+
4
+ class EmiAI:
5
+ def __init__(self, api_key):
6
+ self.api_key = api_key
7
+ self.url = "https://emiai.pythonanywhere.com/v1/chat/completions"
8
+
9
+ def chat(self, message):
10
+ response = requests.post(
11
+ self.url,
12
+ headers={
13
+ "Authorization": f"Bearer {self.api_key}",
14
+ "Content-Type": "application/json",
15
+ "Accept": "application/json",
16
+ },
17
+ json={
18
+ "model": "Emi-o-mini/free",
19
+ "messages": [
20
+ {
21
+ "role": "user",
22
+ "content": message
23
+ }
24
+ ]
25
+ },
26
+ timeout=60
27
+ )
28
+
29
+ try:
30
+ data = response.json()
31
+ except ValueError:
32
+ raise Exception(
33
+ f"EmiAI API returned non-JSON response.\n"
34
+ f"HTTP Status: {response.status_code}\n"
35
+ f"Response:\n{response.text[:2000]}"
36
+ )
37
+
38
+ if response.status_code == 200:
39
+ try:
40
+ return data["choices"][0]["message"]["content"]
41
+ except (KeyError, IndexError, TypeError):
42
+ raise Exception(
43
+ f"Invalid EmiAI API response:\n{data}"
44
+ )
45
+
46
+ raise Exception(
47
+ f"EmiAI API Error ({response.status_code}):\n{data}"
48
+ )
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: emiAi
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for EmiAI API
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: requests>=2.28
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/emiAi/__init__.py
4
+ src/emiAi/client.py
5
+ src/emiAi.egg-info/PKG-INFO
6
+ src/emiAi.egg-info/SOURCES.txt
7
+ src/emiAi.egg-info/dependency_links.txt
8
+ src/emiAi.egg-info/requires.txt
9
+ src/emiAi.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28
@@ -0,0 +1 @@
1
+ emiAi