Skip to main content

CodeGPT python package

Project description

Judini Python Package

The Judini Python library provides convenient access to CodeGPT's Judini REST API from any Python 3.7+ application. The library includes type definitions for all requests parameters and response fields, and offers synchronous and asynchronous clients.

Documentation

The API documentation can be found Here.

Install

To install the package, simply run the following command:

pip install judini

How to get your keys

  1. Create an account at https://app.codegpt.co
  2. Get your CodeGPT Api Key and Org ID from the Apikeys menu

How to use

Chat Completion

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)

AGENT_ID = "0000000-0000-0000-0000-000000000000"
messages = [{"role": "user", "content": "What is the meaning of life?"}]

# No streaming
chat = codegpt.chat_completion(agent_id=AGENT_ID,
                               messages=messages)
print(chat)

# Streaming
for chunk in codegpt.chat_completion(agent_id=AGENT_ID,
...                                  messages=messages,
...                                  stream=True):
    print(chunk, end="")

Agents

List all agents

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.get_agents()
>> [Agent(id='0000000-0000-0000-0000-000000000000', ...),
>>  Agent(id='0000000-0000-0000-0000-000000000001', ...)]

Get agent by ID

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
agent = codegpt.get_agent(agent_id='0000000-0000-0000-0000-000000000000')
agent
>> Agent(id='0000000-0000-0000-0000-000000000000',
>>       name='Agent name', model='gpt-3.5-turbo',
>>       prompt='You are a helpful assistant.',
>>       welcome='Hello, how can I help you?',
>>       ...)

Create Agent

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.create_agent(name='Agent name', model='gpt-3.5-turbo',
...                  prompt='You are a helpful assistant.',
...                  welcome='Hello, how can I help you?')
>> Agent(id='0000000-0000-0000-0000-000000000000',
>>       name='Agent name', model='gpt-3.5-turbo', ...)

Update Agent info

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.update_agent(agent_id='0000000-0000-0000-0000-000000000000',
...                  name='Agent name updated',
...                  model='gpt-4-turbo-preview')
>> Agent(id='0000000-0000-0000-0000-000000000000',
>>       name='Agent name updated', model='gpt-3.5-turbo', ...)                    

Update Agent documents

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.update_agent_documents(agent_id='0000000-0000-0000-0000-000000000000',
...                            document_ids=[DOCUMENT_ID_1, DOCUMENT_ID_2])
>> "Agent documents updated successfully"

Delete Agent

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.delete_agent('0000000-0000-0000-0000-000000000000')
>> "Agent deleted successfully"

Documents

List all documents

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.get_documents()
>> [Document(id='0000000-0000-0000-0000-000000000000', ...),
>>  Document(id='0000000-0000-0000-0000-000000000001', ...)]

Get document by ID

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
document = codegpt.get_document_by_id('0000000-0000-0000-0000-000000000000')
document
>> Document(id='0000000-0000-0000-0000-000000000000',
>>          user_id='...',
>>          name='My Document',
>>          metadata='...',
>>          content='Document content', ...)

Upload a document

Currently, only text documents are supported

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.upload_document('path/to/file.txt', generate_metadata=False)
>> {'id': '0000000-0000-0000-0000-000000000000'}

Update document metadata

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.update_document_metadata(id='0000000-0000-0000-0000-000000000000',
...                              title='My Document Updated',)
>> "Document metadata updated successfully"

Delete a document

from judini import CodeGPTPlus
codegpt = CodeGPTPlus(api_key=CODEGPT_API_KEY, org_id=ORG_ID)
codegpt.delete_document('0000000-0000-0000-0000-000000000000')
>> "Document deleted successfully"

MORE EXAMPLES

You can review more examples in our Cookbook Repository

Changelog

Changelog

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

judini-0.1.12.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

judini-0.1.12-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file judini-0.1.12.tar.gz.

File metadata

  • Download URL: judini-0.1.12.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for judini-0.1.12.tar.gz
Algorithm Hash digest
SHA256 017632b83dbb79418dc97ec2aca1154ab33aabff90a14ad6aa77494ac64d079b
MD5 a6119aade9f55a425d18fc83cc62cc7b
BLAKE2b-256 bc7829d33de49b2e93f71af02cec8f2f1992d1dec1ae8bcccb644b0c71e406d8

See more details on using hashes here.

File details

Details for the file judini-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: judini-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for judini-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 040d42e08996b70042cd7a99d112ae115ee24b6cf483bcaa272b04d8a4f93777
MD5 e628f7963c15dcad5654ab446f92b0ce
BLAKE2b-256 31735aa0477e0e293554dcf0fa0181e16b3fcbb85f54e5c46e723a53f0919226

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