Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

juchats

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

juchats

pipPyPI
Version
0.0.3
Maintainers
1

visitors GitHub

Juchats API wrapper

juchats lib is a Python library designed for interacting with the Juchats API, enabling seamless integration of chat functionalities into your applications. By utilizing this library, developers can leverage the power of advanced models like GPT-4, Claude Mezzo, and deepseek to perform various chat-related tasks.

Installation

pip3 install juchats

Usage

First, obtain your token from from Juchats official website, and place it into a .env file.

JTOKEN=your_token

Basic Chat Interaction

This example demonstrates a simple chat interaction where we ask the model to compare two floating-point numbers.

import os
from juchats.chat import Juchats
from dotenv import load_dotenv
import asyncio
load_dotenv()

async def api():
    token = os.getenv('JTOKEN')
    juchats = Juchats(token, model='deepseek-chat')

    async with juchats:
        await juchats.chat("3.11, 3.9 两个浮点数谁大?具体分析一下,给出你的原因", show_stream=True)

if __name__ == '__main__':
    asyncio.run(api())


''' Output
3.11 大,因为 3.11 > 3.9
'''

Structured JSON output

This example demonstrates how to obtain structured JSON output from the chat API.

import os
from juchats.chat import Juchats
from dotenv import load_dotenv
import asyncio
load_dotenv()

async def api():
    token = os.getenv('JTOKEN')
    juchats = Juchats(token, model='deepseek-chat')
    prompt = "每个月有多少天?以 JSON 格式给出答案,例如:{\"January\": 31, \"February\": 28, ...}"
    async with juchats:
        text = await juchats.chat(prompt)
        print(text)

''' Output
```json
{
    "January": 31,
    "February": 28,
    "March": 31,
    "April": 30,
    "May": 31,
    "June": 30,
    "July": 31,
    "August": 31,
    "September": 30,
    "October": 31,
    "November": 30,
    "December": 31
}
'''

Available Models

By 2024-07-25, the available models (may be outdated) are:

Model IDBackend Model NameFront Model Name
5claude-3-haiku-20240307Claude Mezzo
6claude-3-opus-20240229Claude3 Opus
7mistralai/mixtral-8x22b-instructMixtral Forte
9gpt-4-turbo-2024-04-09GPT Mezzo
10gpt-4-turbo-2024-04-09GPT Forte
11dall-e-3DALL · E3
12meta-llama/llama-3-70b-instructLlama3 70B
13google/gemini-pro-1.5Gemini 1.5 Pro
14deepseek-chatDeepseek
15google/gemini-flash-1.5Gemini-flash
16gpt-4o-2024-05-13GPT4o
17claude-3-opus-20240229Claude3 Opus(100K)
18Stable Image UltraStable Diffusion 3 Ultra
19claude-3-5-sonnet-20240620Claude 3.5 Sonnet
20gpt-4o-mini-2024-07-18GPT4o-mini
21meta-llama/llama-3.1-405b-instructLlama3.1 405B

Get real time available models

Dynamically retrieve the latest available models from the Juchats API.

import os
from juchats.chat import Juchats
from dotenv import load_dotenv
import asyncio
load_dotenv()
token = os.getenv('JTOKEN')
juchats = Juchats(token, model='gpt-4o-2024-05-13')
print(
    asyncio.run(juchats.get_models())
)

Note

  • Streaming: Set show_stream=True to display the chat response in real-time. Use show_stream=False to disable it.
  • Model Selection: Specify the backend model name with the model parameter. Refer to the available models table above for options.
  • API Token: Obtain your token from Juchats and use it to authenticate requests.
  • Rate Limiting: The API supports up to 3 queries per second (QPS). For higher limits, consider using the Deepseek API or OpenAI API.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts