Skip to main content

sparkdesk-api 讯飞星火大模型api

Project description

sparkdesk-api 讯飞星火大模型api

如果该项目对你有帮助,不要忘记给我点个 star,或者 赞助 我一杯蜜雪冰城喔~

使用方法

pip install sparkdesk-api==1.5.0

或者

pip install sparkdesk-api==1.5.0 -i https://pypi.org/simple

1. Web模式

Web模式下,需要前往讯飞星火大模型web端通过 F12 抓取 3 个参数:cookie、fd、GtToken

命令行操作

python sparkdesk_web_cli.py

api调用

  • chat():一次询问
  • chat_stream():连续询问,相当于命令行模式
from sparkdesk_web.core import SparkWeb

sparkWeb = SparkWeb(
     cookie=cookie,
     fd=fd,
     GtToken=GtToken
 )

 # single chat
 print(sparkWeb.chat("repeat: hello world"))
 # continue chat
 sparkWeb.chat_stream()

2. API模式

支持v3.0、v2.0、v1.0 三个版本,默认接口版本为3.0

  • 默认api接口版本为3.1,配置其他版本需要指定Version参数(2.1或者1.1)

讯飞星火的API需要前往官网进行申请。 你可以先创建一个服务,然后在该服务的控制台页面左边的:“星火认知大模型”栏目,进入“合作咨询”页面进行申请。 一般使用公司邮箱申请速度快。

该模式需要 3 个参数:app_id、api_key、api_secret

from sparkdesk_api.core import SparkAPI
# 默认api接口版本为3.1,配置其他版本需要指定Version参数(2.1或者1.1)
sparkAPI = SparkAPI(
    app_id=app_id,
    api_secret=api_secret,
    api_key=api_key,
    # version=2.1
)
sparkAPI.chat_stream()

具体调用方法与相关调用函数与 Web 模式一致。

🙏 赞助

如果项目对您有帮助,可以赞助我一杯蜜雪冰城哦~

🤝贡献

🎉鸣谢

感谢以下开发者对该项目做出的贡献:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparkdesk-api-1.5.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

sparkdesk_api-1.5.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file sparkdesk-api-1.5.0.tar.gz.

File metadata

  • Download URL: sparkdesk-api-1.5.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for sparkdesk-api-1.5.0.tar.gz
Algorithm Hash digest
SHA256 3249c9e93ddd3a53dbd8b7337f4e6704eae768c9987e69623aed037ceaa15d12
MD5 6fcdf384af62321109a96a2ac3d2d6a9
BLAKE2b-256 659fb5e3e75f20d9c66ab6e1ea5149a3b729a0815971a384a1eef43e6ae1f9c5

See more details on using hashes here.

File details

Details for the file sparkdesk_api-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sparkdesk_api-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a554528acfe5b54c73dc49b8983f053c2907a6ab2630baabcfa87fe741581178
MD5 1da641fea990e9e8b20d3ae5f14af837
BLAKE2b-256 7ba881eb9681615071bffc43c45dfe5f2d3e7fd1cd58199620f96a028ec927a7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page