Skip to content

Commit

Permalink
add support for V3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
suqingdong committed Oct 26, 2023
1 parent 2ff4fa2 commit 168d963
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Installation
```bash
python3 -m pip install sparkapi-python
python3 -m pip install -U sparkapi-python
```

## Configuration
Expand All @@ -12,8 +12,8 @@ python3 -m pip install sparkapi-python
SPARK_APP_ID=<your-app-id>
SPARK_API_SECRET=<your-api-secret>
SPARK_API_KEY=<your-api-key>
SPARK_API_MODEL='v2.0' # v1.5, v2.0
SPARK_CHAT_MAX_TOKENS=4096 # 1-4096
SPARK_API_MODEL='v3.0' # v1.5, v2.0, v3.0
SPARK_CHAT_MAX_TOKENS=4096 # v1.5: 1-4096, v2.0: 1-8192
SPARK_CHAT_TEMPERATURE=0.5 # 0-1
SPARK_CHAT_TOP_K=4 # 1-6
```
Expand Down
4 changes: 2 additions & 2 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SPARK_APP_ID=<your-app-id>
SPARK_API_SECRET=<your-api-secret>
SPARK_API_KEY=<your-api-key>
SPARK_API_MODEL='v2.0' # v1.5, v2.0
SPARK_CHAT_MAX_TOKENS=4096 # 1-4096
SPARK_API_MODEL='v2.0' # v1.5, v2.0, v3.0
SPARK_CHAT_MAX_TOKENS=4096 # v1.5: 1-4096, v2.0: 1-8192
SPARK_CHAT_TEMPERATURE=0.5 # 0-1
SPARK_CHAT_TOP_K=4 # 1-6
2 changes: 2 additions & 0 deletions sparkapi/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def get_completion_from_messages(self, messages: List[dict], **kwargs):
wss = self.create_wss_connection()

query = self.build_query(messages, **kwargs)
from pprint import pprint
# pprint(query)
wss.send(query)

while True:
Expand Down
4 changes: 4 additions & 0 deletions sparkapi/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
'domain': 'generalv2',
'url': 'wss://spark-api.xf-yun.com/v2.1/chat',
},
'v3.0': {
'domain': 'generalv3',
'url': 'wss://spark-api.xf-yun.com/v3.1/chat',
},
}
1 change: 1 addition & 0 deletions sparkapi/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class Domain(Enum):
GENERAL = 'general'
GENERAL_V2 = 'generalv2'
GENERAL_V3 = 'generalv3'

def __str__(self):
return self.value
Expand Down
2 changes: 1 addition & 1 deletion sparkapi/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"url": "https://github.com/suqingdong/sparkapi",
"author": "suqingdong",
"author_email": "suqingdong1114@gmail.com",
"version": "1.0.2"
"version": "1.0.3"
}

0 comments on commit 168d963

Please sign in to comment.