Giter VIP home page Giter VIP logo

st1vms / unofficial-claude-api Goto Github PK

View Code? Open in Web Editor NEW
98.0 6.0 10.0 73 KB

Unofficial Claude API supporting direct HTTP chat creation/deletion/retrieval, messages with multiple file attachments and auto session gathering using Firefox with geckodriver.

License: MIT License

Python 100.00%
claude claude-api firefox python selenium unofficial-api api chatbot documented file-attachment

unofficial-claude-api's People

Contributors

kyhhdm avatar st1vms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unofficial-claude-api's Issues

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Python 3.9.18 (main, Aug 25 2023, 13:20:04)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

from claude2_api import *
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.9/dist-packages/claude2_api/init.py", line 2, in
from .client import (
File "/usr/local/lib/python3.9/dist-packages/claude2_api/client.py", line 21,
in
from .session import SessionData
File "/usr/local/lib/python3.9/dist-packages/claude2_api/session.py", line 41, in
def get_session_data(profile: str = "", quiet: bool = False) -> SessionData
| None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Invalid model

Error code 403, response -> {"error":{"type":"permission_error","message":"Invalid model","code":"model_not_allowed"}}

Please add 'model_claude' to 'client.send_message'

res: SendMessageResponse = client.send_message(
        chat_id=chat_id, prompt="Hello! Tell me about yourself", model_claude="claude-2.0"
)

Streaming Messages Support

Does this package support streaming messages like the official package?

import anthropic

client = anthropic.Anthropic()

with client.messages.stream(
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
    model="claude-3-opus-20240229",
) as stream:
  for text in stream.text_stream:
      print(text, end="", flush=True)

Request failed with status code: 403

raise RuntimeError(f"Cannot retrieve Organization ID!\n{response.text}")
RuntimeError: Cannot retrieve Organization ID!
{"error": {"type": "permission_error", "message": "We are unable to serve your request"}}

Claude 3?

When should we expect an update for claude 3?

Error code 200, response -> {}

Sometimes I get an error

Error code 200, response -> {} 

My code:

if file is not None and os.path.exists(file):
    res: SendMessageResponse = client.send_message(
        chat_id=chat_id, prompt=text, attachment_paths=[file]
    )
else:
    res: SendMessageResponse = client.send_message(
        chat_id=chat_id, prompt=text
    )

if res.answer:
    result_answer = res.answer
else:
    self.__msg.error(f'Error code {res.status_code}, response -> {res.error_response} // MSG:{msg_num}', than_exit=False)
    self.__msg.error(f'{res}', than_exit=True)

res is:

SendMessageResponse(answer='', status_code=200, error_response={}) 

Any idea how fix this?

PS. But if i go to the Web, there's an answer in chat.

Unable to prepare file attachment

I tried uploading PDF file, which is not more than 10MB and give me this: [403] Unable to prepare file attachment -> myPDF.pdf
when I tried uploading it directly to the web to check if my PDF will upload, it uploads.

RuntimeError: Cannot retrieve Organization ID

RuntimeError: Cannot retrieve Organization ID!
{"error": {"type": "permission_error", "message": "We are unable to serve your request"}}

I've tried a couple of unofficial claude2 api projects and I always get this error. It looks like claude has disabled analog browser access? I'm curious to know if a solution exists.

UnicodeDecodeError in .send_message

Error:

line 393, in send_message
    err = json.loads(response.content.decode("utf-8"))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 0: invalid start byte

My code:

def test(cookies):
    user_agent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36"

    data = SessionData(cookies, user_agent)

    client = ClaudeAPIClient(data)

    prompt = "Wassup"

    file_path_list = []

    chat_id = client.create_chat()

    if not chat_id:
        return "Message limit hit, cannot create chat. Please try again later..."

    else:
        print(chat_id)

    try:
        res: SendMessageResponse = client.send_message(
            chat_id, "hello", timeout=240
        )

        if res.answer:
            return res.answer
        else:
            client.delete_chat(chat_id)
            return f"Error code {res.status_code}, response -> {res.error_response}"

    except MessageRateLimitError as e:
        client.delete_chat(chat_id)
        return f"Message limit hit, resets at {e.resetDate}. {e.sleep_sec} seconds left until -> {e.resetTimestamp}"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.