Skip to content

Commit 7a64df6

Browse files
authored
Merge pull request #5 from samestrin/2.0.7
2.0.7
2 parents 51d0c29 + 469617d commit 7a64df6

29 files changed

+752
-1283
lines changed

README.md

+15-17
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,33 @@
22

33
[![Star on GitHub](https://img.shields.io/github/stars/samestrin/llm-interface?style=social)](https://github.com/samestrin/llm-interface/stargazers) [![Fork on GitHub](https://img.shields.io/github/forks/samestrin/llm-interface?style=social)](https://github.com/samestrin/llm-interface/network/members) [![Watch on GitHub](https://img.shields.io/github/watchers/samestrin/llm-interface?style=social)](https://github.com/samestrin/llm-interface/watchers)
44

5-
![Version 2.0.6](https://img.shields.io/badge/Version-2.0.6-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Built with Node.js](https://img.shields.io/badge/Built%20with-Node.js-green)](https://nodejs.org/)
5+
![Version 2.0.7](https://img.shields.io/badge/Version-2.0.7-blue) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Built with Node.js](https://img.shields.io/badge/Built%20with-Node.js-green)](https://nodejs.org/)
66

77
## Introduction
88

9-
`llm-interface` is a wrapper designed to interact with multiple Large Language Model (LLM) APIs. `llm-interface` simplifies integrating various LLM providers, including **OpenAI, AI21 Studio, Anthropic, Cloudflare AI, Cohere, Fireworks AI, Google Gemini, Goose AI, Groq, Hugging Face, Mistral AI, Perplexity, Reka AI, watsonx.ai, and LLaMA.cpp**, into your applications. It is available as an [NPM package](https://www.npmjs.com/package/llm-interface).
9+
`llm-interface` is a wrapper designed to interact with multiple Large Language Model (LLM) APIs. `llm-interface` simplifies integrating various LLM providers, including **OpenAI, AI21 Studio, Anthropic, Cloudflare AI, Cohere, DeepInfra, Fireworks AI, Friendli AI, Google Gemini, Goose AI, Groq, Hugging Face, Mistral AI, Monster API, Octo AI, Perplexity, Reka AI, watsonx.ai, and LLaMA.cpp (ollama compatible)**, into your applications. It is available as an [NPM package](https://www.npmjs.com/package/llm-interface).
1010

1111
This goal of `llm-interface` is to provide a single, simple, unified interface for sending messages and receiving responses from different LLM services. This will make it easier for developers to work with multiple LLMs without worrying about the specific intricacies of each API.
1212

1313
## Features
1414

15-
- **Unified Interface**: `LLMInterfaceSendMessage` is a single, consistent interface to interact with **fifteen** different LLM APIs.
15+
- **Unified Interface**: `LLMInterfaceSendMessage` is a single, consistent interface to interact with **19 different LLM APIs**.
1616
- **Dynamic Module Loading**: Automatically loads and manages LLM interfaces only when they are invoked, minimizing resource usage.
1717
- **Error Handling**: Robust error handling mechanisms to ensure reliable API interactions.
1818
- **Extensible**: Easily extendable to support additional LLM providers as needed.
1919
- **Response Caching**: Efficiently caches LLM responses to reduce costs and enhance performance.
2020
- **Graceful Retries**: Automatically retry failed prompts with increasing delays to ensure successful responses.
2121
- **JSON Output**: Simple to use native JSON output for OpenAI, Fireworks AI, and Gemini responses.
22-
- **JSON Repair**: Detect and repair invalid JSON responses.
22+
- **JSON Repair**: Detect and repair invalid JSON responses.
2323

2424
## Updates
2525

26+
**v2.0.7**
27+
28+
- **New LLM Providers**: Added support for DeepInfra, FriendliAI, Monster API, Octo AI, Together AI, and NVIDIA.
29+
- **Improved Test Coverage**: New DeepInfra, FriendliAI, Monster API, NVIDIA, Octo AI, Together AI, and watsonx.ai test cases.
30+
- **Refactor**: Improved support for OpenAI compatible APIs using new BaseInterface class.
31+
2632
**v2.0.6**
2733

2834
- **New LLM Provider**: Added support for watsonx.ai.
@@ -31,16 +37,6 @@ This goal of `llm-interface` is to provide a single, simple, unified interface f
3137

3238
- **New LLM Providers Functions**: `LLMInterface.getAllModelNames()` and `LLMInterface.getModelConfigValue(provider, configValueKey)`.
3339

34-
**v2.0.2**
35-
36-
- **New LLM Providers**: Added support for Cloudflare AI, and Fireworks AI.
37-
- **JSON Consistency**: A breaking change has been introduced: all responses now return as valid JSON objects.
38-
- **JSON Repair**: Use `interfaceOptions.attemptJsonRepair` to repair invalid JSON responses when they occur.
39-
- **Improved Hugging Face Interface**: Refactored interface to support the undocumented chat completion endpoint.
40-
- **Interface Name Changes**:`reka` becomes `rekaai`, `goose` becomes `gooseai`, `mistral` becomes `mistralai`.
41-
- **Deprecated**: `handlers` has been removed.
42-
- **Updated LLM Model Definitions**: Revised `small` models for various providers.
43-
4440
## Dependencies
4541

4642
The project relies on several npm packages and APIs. Here are the primary dependencies:
@@ -120,12 +116,14 @@ npm test
120116
#### Test Results (v2.0.0)
121117

122118
```bash
123-
Test Suites: 46 passed, 46 total
124-
Tests: 185 passed, 185 total
119+
Test Suites: 52 passed, 52 total
120+
Tests: 2 skipped, 215 passed, 217 total
125121
Snapshots: 0 total
126-
Time: 61.064 s, estimated 64 s
122+
Time: 76.236 s
127123
```
128124

125+
_Note: Currently skipping NVIDIA test cases due to API key limits._
126+
129127
## Contribute
130128

131129
Contributions to this project are welcome. Please fork the repository and submit a pull request with your changes or improvements.

docs/APIKEYS.md

+37-1
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ The Cohere API offers trial keys. Trial keys are rate-limited, and cannot be use
3232

3333
- https://dashboard.cohere.com/api-keys
3434

35+
## Deepinfra
36+
37+
The Deepinfra API is commercial but new accounts will start with a $1.80 credit.
38+
3539
## Fireworks AI
3640

3741
The Fireworks AI API offers a free developer tier and commercial accounts. A Credit is not required for the free developer tier.
3842

3943
- https://fireworks.ai/api-keys
4044

45+
## Friendli AI
46+
47+
The Friendli AI API is commercial but it comes with a $5.00 credit.
48+
49+
- https://suite.friendli.ai/user-settings/tokens
50+
4151
## Gemini
4252

4353
The Gemini API is currently free.
@@ -68,6 +78,26 @@ The MistralAI API is a commercial product, but it currently does not require a c
6878

6979
- https://console.mistralai.ai/api-keys/
7080

81+
## Monster API
82+
83+
The Monster API is commercial but it comes with a free tier. You do not need to provide a credit card to get started.
84+
85+
- https://monsterapi.ai/user/dashboard
86+
87+
## NVIDIA
88+
89+
The NVIDIA API comes with 1000 credits, however they run out fast. To get an API key, first navigate to a model like:
90+
91+
- https://build.nvidia.com/meta/llama3-70b
92+
93+
Then click "Get API Key" on the right side of the page.
94+
95+
## Octo AI
96+
97+
The Octo AI API is commercial, but it comes with a $5.00 credit, and does not require a credit card.
98+
99+
- https://octoai.cloud/settings
100+
71101
## Perplexity
72102

73103
The Perplexity API requires a credit cards.
@@ -76,10 +106,16 @@ The Perplexity API requires a credit cards.
76106

77107
## Reka AI
78108

79-
The Reka AI API requires a credit card, but currently comes with a $5 credit.
109+
The Reka AI API requires a credit card, but currently comes with a $5.00 credit.
80110

81111
- https://platform.reka.ai/apikeys
82112

113+
## Together AI
114+
115+
The Together API is commercial, but it did not require a credit card, and it came with a $5.00 credit.
116+
117+
- https://api.together.xyz/settings/api-keys
118+
83119
## watsonx.ai
84120

85121
The watsonx.ai API is a commercial service, but it offers a free tier of service without requiring a credit card.

env

+11-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,14 @@ AI21_API_KEY=
1111
FIREWORKSAI_API_KEY=
1212
CLOUDFLARE_API_KEY=
1313
CLOUDFLARE_ACCOUNT_ID=
14-
LLAMACPP_URL=http://localhost:8080/completions
14+
LLAMACPP_URL=http://localhost:8080/completions
15+
CLOUDFLARE_API_KEY=
16+
CLOUDFLARE_ACCOUNT_ID=
17+
WATSONXSAI_API_KEY=
18+
WATSONXSAI_SPACE_ID=
19+
FRIENDLIAI_API_KEY=
20+
NVIDIA_API_KEY=
21+
DEEPINFRA_API_KEY=
22+
TOGETHERAI_API_KEY=
23+
MONSTERAPI_API_KEY=
24+
OCTOAI_API_KEY=

src/config/config.js

+5
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ module.exports = {
2424
watsonxaiApiKey: process.env.WATSONXSAI_API_KEY,
2525
watsonxaiSpaceId: process.env.WATSONXSAI_SPACE_ID,
2626
friendliaiApiKey: process.env.FRIENDLIAI_API_KEY,
27+
nvidiaApiKey: process.env.NVIDIA_API_KEY,
28+
deepinfraApiKey: process.env.DEEPINFRA_API_KEY,
29+
togetheraiApiKey: process.env.TOGETHERAI_API_KEY,
30+
monsterapiApiKey: process.env.MONSTERAPI_API_KEY,
31+
octoaiApiKey: process.env.OCTOAI_API_KEY,
2732
};

src/config/llmProviders.json

+61-3
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@
136136
},
137137
"small": {
138138
"name": "accounts/fireworks/models/phi-3-mini-128k-instruct",
139-
"tokens": 128000
139+
"tokens": 4096
140140
}
141141
}
142142
},
143143
"friendliai": {
144144
"url": "https://inference.friendli.ai/v1/chat/completions",
145145
"model": {
146-
"default": { "name": "mixtral-8x7b-instruct-v0-1", "tokens": 32768 },
146+
"default": { "name": "mixtral-8x7b-instruct-v0-1", "tokens": 4096 },
147147
"large": { "name": "meta-llama-3-70b-instruct", "tokens": 8192 },
148-
"small": { "name": "mistral-7b-instruct-v0-2", "tokens": 4096 }
148+
"small": { "name": "meta-llama-3-8b-instruct", "tokens": 4096 }
149149
}
150150
},
151151
"watsonxai": {
@@ -155,5 +155,63 @@
155155
"large": { "name": "meta-llama/llama-3-70b-instruct", "tokens": 8192 },
156156
"small": { "name": "google/flan-t5-xxl", "tokens": 512 }
157157
}
158+
},
159+
"nvidia": {
160+
"url": "https://integrate.api.nvidia.com/v1/chat/completions",
161+
"model": {
162+
"default": { "name": "nvidia/llama3-chatqa-1.5-8b", "tokens": 4096 },
163+
"large": { "name": "nvidia/nemotron-4-340b-instruct", "tokens": 4096 },
164+
"small": { "name": "microsoft/phi-3-mini-128k-instruct", "tokens": 4096 }
165+
}
166+
},
167+
"deepinfra": {
168+
"url": "https://api.deepinfra.com/v1/openai/chat/completions",
169+
"model": {
170+
"default": { "name": "openchat/openchat-3.6-8b", "tokens": 8192 },
171+
"large": { "name": "nvidia/nemotron-4-340b-instruct", "tokens": 4096 },
172+
"small": { "name": "microsoft/WizardLM-2-7B", "tokens": 4096 }
173+
}
174+
},
175+
"togetherai": {
176+
"url": "https://api.together.xyz/v1/chat/completions",
177+
"model": {
178+
"default": {
179+
"name": "deepseek-ai/deepseek-llm-67b-chat",
180+
"tokens": 4096
181+
},
182+
"large": {
183+
"name": "NousResearch/Nous-Hermes-2-Mixtral-8x22B-Instruct",
184+
"tokens": 65536
185+
},
186+
"small": { "name": "Qwen/Qwen1.5-0.5B-Chat", "tokens": 32768 }
187+
}
188+
},
189+
"monsterapi": {
190+
"url": "https://llm.monsterapi.ai/v1/chat/completions",
191+
"model": {
192+
"default": {
193+
"name": "microsoft/Phi-3-mini-4k-instruct",
194+
"tokens": 4096
195+
},
196+
"large": {
197+
"name": "meta-llama/Meta-Llama-3-8B-Instruct",
198+
"tokens": 4096
199+
},
200+
"small": { "name": "TinyLlama/TinyLlama-1.1B-Chat-v1.0", "tokens": 2048 }
201+
}
202+
},
203+
"octoai": {
204+
"url": "https://text.octoai.run/v1/chat/completions",
205+
"model": {
206+
"default": {
207+
"name": "mistral-7b-instruct",
208+
"tokens": 32768
209+
},
210+
"large": {
211+
"name": "mixtral-8x22b-instruct",
212+
"tokens": 65536
213+
},
214+
"small": { "name": "mistral-7b-instruct", "tokens": 32768 }
215+
}
158216
}
159217
}

0 commit comments

Comments
 (0)