Skip to content

Commit

Permalink
document overriding the api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
brainlid committed Dec 11, 2023
1 parent a946604 commit fc91afe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ IO.put message.content
#=> "The hairbrush is located in the drawer."
```

### Alternative OpenAI compatible APIs

There are several of services or self-hosted applications that provide an OpenAI compatible API for ChatGPT-like behavior. To use a service like that, the `endpoint` of the `ChatOpenAI` struct can be pointed to an API compatible `endpoint` for chats.

For example, if a locally running service provided that feature, the following code could connect to the service:

```elixir
{:ok, updated_chain, %Message{} = message} =
LLMChain.new!(%{
llm: ChatOpenAI.new!(%{endpoint: "http://localhost:1234/v1/chat/completions"}),
})
|> LLMChain.add_message(Message.new_user!("Hello!"))
|> LLMChain.run()
```

## Testing

To run all the tests including the ones that perform live calls against the OpenAI API, use the following command:
Expand Down

0 comments on commit fc91afe

Please sign in to comment.