Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable compatibility with OpenAI-compatible APIs #65

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
node_modules
node_modules
apps
cofounder/api/db
package-lock.json
4 changes: 3 additions & 1 deletion cofounder/api/.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
PORT = 4200

OPENAI_BASE_URL="https://api.openai.com/v1" # Replace with your OpenAI-compatible API base URL if you are using a service similar to OpenAI’s APIs
OPENAI_API_KEY = "REPLACE_WITH_OPENAI_KEY"
OPENAI_MODEL="gpt-4o-mini"
ANTHROPIC_API_KEY = "REPLACE_WITH_ANTHROPIC_KEY"
COFOUNDER_API_KEY = "REPLACE_WITH_COFOUNDER.OPENINTERFACE.AI_KEY"

# llm, can be 'ANTHROPIC' (for claude sonnet 3.5) or 'OPENAI' (uses diff. models for diff. passes)
# make sure there are matching api keys
LLM_PROVIDER = "ANTHROPIC" #"OPENAI"
LLM_PROVIDER = "OPENAI" #"OPENAI"

# should be kept to "text-embedding-3-small" to work with RAG using api.cofounder.openinterface.ai
EMBEDDING_MODEL = "text-embedding-3-small"
Expand Down
3 changes: 2 additions & 1 deletion cofounder/api/utils/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ let openai;
try {
openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL || "https://api.openai.com/v1",
});
} catch (e) {
console.error("utils:openai : " + e);
}

async function inference({
model = `gpt-4o-mini`,
model = process.env.OPENAI_MODEL || `gpt-4o-mini`,
messages,
stream = process.stdout,
}) {
Expand Down