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

[Feature]: Support Custom API Key Formats and Server Addresses #291

Open
XiaomaiTX opened this issue Jan 6, 2024 · 6 comments
Open

[Feature]: Support Custom API Key Formats and Server Addresses #291

XiaomaiTX opened this issue Jan 6, 2024 · 6 comments

Comments

@XiaomaiTX
Copy link

XiaomaiTX commented Jan 6, 2024

Description

I would like to request the addition of a feature to allow for the customization of API key formats and the API server address, providing flexibility for users with diverse API key structures.

Suggested Solution

Introduce configuration options to set custom API key formats and a custom API server address. This can be achieved by adding commands similar to:

oco config set OCO_CUSTOM_API_KEY_PATTERN=<custom_key_pattern>

oco config set OCO_CUSTOM_API_SERVER=<custom_server_address>

Where <custom_key_pattern> represents the user-defined API key pattern, and <custom_server_address> represents the user-defined API server address.

Alternatives

Upon setting custom API key formats and a server address, OpenCommit should utilize the specified formats for API requests instead of the default settings.

Additional Context

No response

@XiaomaiTX XiaomaiTX changed the title [Feature]: Add Custom API Server Address Configuration [Feature]: Support Custom API Key Formats and Server Addresses Jan 6, 2024
Copy link

Stale issue message

@di-sukharev
Copy link
Owner

reopening, will take a look at this

@sebastienfi
Copy link
Contributor

Currently OpenCommit supports two engines:

  • OpenAI, which have a specific pattern for validating API keys input by OCO users. This service can be proxied (eventually including a custom basepath).
  • Ollama which can be hosted anywhere, and does not have a specific pattern for the API key.
[CONFIG_KEYS.OCO_OPENAI_API_KEY](value: any, config: any = {}) {
  //need api key unless running locally with ollama
  validateConfig(
    'API_KEY',
    value || config.OCO_AI_PROVIDER == 'ollama',
    'You need to provide an API key'
  );
  validateConfig(
    CONFIG_KEYS.OCO_OPENAI_API_KEY,
    value.startsWith('sk-'),
    'Must start with "sk-"'
  );
  validateConfig(
    CONFIG_KEYS.OCO_OPENAI_API_KEY,
    config[CONFIG_KEYS.OCO_OPENAI_BASE_PATH] || value.length === 51,
    'Must be 51 characters long'
  );

  return value;
},

@XiaomaiTX Could you please elaborate on the feature you would like to have? It seems you would like to have the ability to make calls to an LLM API specifying the URL of its backend, possibly another engine. Please enlighten us.

@XiaomaiTX
Copy link
Author

@sebastienfi Another friend and I developed a project called ChatNio, which is an AI model aggregation platform, which means that users can access different back-end AI services supported by ChatNio through a unified API interface. The use of ChatNio's API interface is the same as that of OpenAI's API interface, but the length of the custom API key we provide is different from that of the official API Key of OpenAI, which causes problems when I want to connect the ChatNio service to opencommit in OpenAI format.

@sebastienfi
Copy link
Contributor

sebastienfi commented Mar 6, 2024

I see. Then this is simply about removing the business rule which validates the OpenAI API Key format. The code that needs to change is the one I provided earlier.
Anyway, I don't think we should validate this key, that seems out of scope for OCO.
@XiaomaiTX Would you like to submit a PR?

@XiaomaiTX
Copy link
Author

@sebastienfi It's my honor if I can submit a PR for this project!❤️

Can I submit PR tomorrow or the day after tomorrow? I'm a little busy today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants