Giter VIP home page Giter VIP logo

anthropic's People

Contributors

alexrudall avatar deepakmahakale avatar dependabot[bot] avatar svs avatar swombat 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

Watchers

 avatar  avatar  avatar

anthropic's Issues

Add Streaming!

  • Need streaming to make this library more useful in prod!

Abstraction Layers for building Messages payload

Is your feature request related to a problem? Please describe.

Building the payload for messages it's prone to errors and it gets more complex when you need to add images. I was thinking if a layer that handle that for you would be useful for this library or it's something that it should be left to other projects such as boxcars.

Describe the solution you'd like

Abstraction layers that handle building a messages array for the payload.

Describe alternatives you've considered
A class that handles the building of the message's payload, something a Anthropic::MessagesBuilder, that it would build the payload according to what is required (User message without previous messages, chat history, user message with an image or multiple images, etc.)

A class for Messages (it could be Anthropic::Message with attributes ´role´ (´user´ or ´assistant´) and ´content´. Content can be text or image.

It could also be a small gem just for this one. I'm also wondering if it would be just okay use other gems such boxcars or lanchainrb, or it would be a nice addition to this gem.

Additional context
Add any other context or screenshots about the feature request here.

Better handling of parameter errors

As I tested the new streaming functionality, I found that when the parameters are not quite right it semi-silently fails:

3.3.0 :044 > params
 => 
{:model=>"claude-3-haiku-20240307",
 :temperature=>0.9,
 :max_tokens=>4096,
 :messages=>
  [{:role=>"user",
    :content=>
     "Some kind of preamble that doesn't have arguments.\n\nSample Script Contents 1\n\nAnother section yay\n\nSample Script Contents 1 and Input Item in Special Instruction\n\nThis section has a lot of lines\nIt is here to test the lines.\n\nLet's have some more text:\n\nThis will prevent RuboCop from checking the Sample Script Contents 2 syntax style throughout your entire codebase. Make sure to place this under the correct hierarchy in your .rubocop.yml file, typically at the root level or under a specific target if you have Sample Script Contents 1 configurations for different parts of your project."}],
 :stream=>true,
 :preprocess_stream=>:text} 
3.3.0 :045 > @client.messages(parameters:params)
 => {"type"=>"error", "error"=>{"type"=>"invalid_request_error", "message"=>"preprocess_stream: Extra inputs are not permitted"}} 

I wonder if these kinds of errors (invalid requests in particular) should actually result in an Anthropic::Error being raised.

I can add this code if you think it makes sense.

Streaming error mishandled in http.rb

Line 154 in http.rb on env is nil on valid requests. This causes merge to error on line 157

 return unless env&.status != 200

Example:

          response = anthropic_client.messages(
            parameters: {
              temperature: 0.7,
              model: model,
              messages: message_data
              max_tokens: 100,
              preprocess_stream: :text,
              stream: proc do |incremental_response, delta|
                next if delta.blank?
                Rails.logger.info "Incremental response: #{incremental_response}"
                Rails.logger.info "Delta: #{delta}"
              end
            })  

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.