Open BenTheCloudGuy opened 6 months ago
Would you be able and willing to test such implementation? Do you have a summary of important differences from OpenAI API on hand?
along with other implementations
Which ones, for example?
More than willing and happy to help. I'm not a developer, but have been going down the path of building out a functional solution for using ChatGPT3.5 with my own data pulled from Azure Blob Storage. As a full disclosure I work for MSFT as an Azure CSA, so that is the reason I'm looking at this solution vs native OpenAI API.
The biggest changes will be the URL API Endpoint which is variable based on the Azure OpenAI deployment along with the following: "CHATGPT_MODEL":"{{model-deployment-name}}", <-- Pulled from the Azure Portal and a user created string "OPENAI_API_BASE":"https://{{openai-deployment-name}}.openai.azure.com/", <-- Pulled from the portal and is the name of the Azure OpenAI deployment resource. "OPENAI_API_VERSION":"2023-03-15-preview", "OPENAI_API_TYPE": "azure",
I've gotten things working via Python, but I was using the OpenAI Libraries (via import openai):
def chatbot(openAIKey,configDetails,prompt):
## Collect values from Config File.
chatgpt_model_name = configDetails['CHATGPT_MODEL']
openai.api_type = configDetails['OPENAI_API_TYPE']
openai.api_key = openAIKey
openai.api_base = configDetails['OPENAI_API_BASE']
openai.api_version = configDetails['OPENAI_API_VERSION']
response = openai.ChatCompletion.create(
engine=chatgpt_model_name,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
)
# Return the response
return (response['choices'][0]['message']['content'])
I was thinking we could add some additional Game Settings to settings.js:
Allow adding a custom 'customEndpoingUrl' that can be any API Endpoint the user needs.
game.settings.register(moduleName, 'endpointUrl', {
name: 'ChatGPT Base URI',
hint: 'You can either use the default OpenAI EndPoint or Azure OpenAI Endpoint.',
scope: 'world',
config: true,
type: String,
default: ''
});
Remove the "selection" option from 'modelVersion' to allow a user entered string. Along with updating the hint with some better instructions.
game.settings.register(moduleName, 'modelVersion', {
name: 'ChatGPT model version',
hint: 'Version of the ChatGPT model to use. Free accounts do not have access to GPT-4. If you are using Azure OpenAI, use the Model Name from the API endpoint URL.',
scope: 'world',
config: true,
type: String,
default: ''
});
Is there a reason you didn't use the built in OpenAI Libraries for javascript?
@BenTheCloudGuy could you comment (and maybe check) if the implementation like in #15 is sufficient?
Regarding the modelVersion
— isn't there an endpoint that lists the available models (presumably, /v1/models
)? Could you provide an example string you personally would use for this field (just so I have some idea of the potential differences)?
@BenTheCloudGuy could you comment (and maybe check) if the implementation like in #15 is sufficient?
Regarding the
modelVersion
— isn't there an endpoint that lists the available models (presumably,/v1/models
)? Could you provide an example string you personally would use for this field (just so I have some idea of the potential differences)?
Sorry - work and life got crazy busy as I'm prepping everything for GenCon in about a month and we are end of Fiscal Year at work. I'll get this tested out asap and reply back.
I would love to see the option to pass in specific API Endpoints so that we can leverage Azure OpenAI API along with other implementations.