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 request]: support for azure hosted openai models? #179

Closed
mariusgarmhausen opened this issue Mar 11, 2024 · 23 comments · Fixed by AtheeSouhait/fabric#1
Closed

[Feature request]: support for azure hosted openai models? #179

mariusgarmhausen opened this issue Mar 11, 2024 · 23 comments · Fixed by AtheeSouhait/fabric#1
Labels
enhancement New feature or request

Comments

@mariusgarmhausen
Copy link

What do you need?

I was wondering if Azure hosted endpoints are already implemented?

@mariusgarmhausen mariusgarmhausen added the enhancement New feature or request label Mar 11, 2024
@streichsbaer
Copy link
Contributor

I was also looking for the Azure OpenAI option, but it's not yet supported.

@danielmiessler, I'd be happy to create a PR for that feature.

Let me know.

@GuizzyQC
Copy link

Try adding a OPENAI_BASE_URL= line in ~/.config/fabric/.env

It does complain about "Unable to fetch models" and "No OpenAI API key found" (despite having an API key too), as elsewhere in the code it does fetch a list of models from a hardcoded OpenAI URL, but outside of that it does work for me on a different OpenAI API compatible endpoint.

@bjcbusiness
Copy link

Try adding a OPENAI_BASE_URL= line in ~/.config/fabric/.env

It does complain about "Unable to fetch models" and "No OpenAI API key found" (despite having an API key too), as elsewhere in the code it does fetch a list of models from a hardcoded OpenAI URL, but outside of that it does work for me on a different OpenAI API compatible endpoint.

This doesn't work at all for me. Looking forward to proper support for Azure.

@vfarcic
Copy link

vfarcic commented May 31, 2024

👍 for Azure OpenAI support

@AtheeSouhait
Copy link

Made it working with my Azure openai deployment, you can test:
https://github.com/AtheeSouhait/fabric/tree/AtheeSouhait-AzureOpenAIonCLI

New environment variables must contain:
AZURE_OPENAI_API_KEY
AZURE_OPENAI_ENDPOINT
AZURE_OPENAI_API_VERSION
AZURE_OPENAI_MODEL
for example:
export AZURE_OPENAI_API_VERSION=2024-02-15-preview
export AZURE_OPENAI_ENDPOINT=https://yourdeploymentendpoint.openai.azure.com/
export AZURE_OPENAI_MODEL=myGPT4-32k
export AZURE_OPENAI_API_KEY=yourazureopenaideploymentapikey

@bjcbusiness
Copy link

bjcbusiness commented Jun 4, 2024 via email

@stefanstranger
Copy link

Hi @AtheeSouhait, I followed your instructions and copied your code changes but I don't see the model being showed when running fabric --listmodels.

image

What else do I need to change to support Azure OpenAI?

Thanks for your help.
/Stefan

@AtheeSouhait
Copy link

Hi @stefanstranger , indeed the update don't modify output of --listmodel so it is not included in the list. But your setting automaticaly uses your AZURE open ai model. By the way, if you want to use OPENAI model and not the Azure; comment the AZURE_OPENAI_API_KEY line of your .env so it is not taken as default.
I should have also adapted this "listmodel" part of the code. I'll do if I have the time but as the project will move to "go" language implementation, I'm not sure it worth the effort, what do you think?

@stefanstranger
Copy link

stefanstranger commented Jun 19, 2024

Hi @AtheeSouhait,

Thanks for your quick response 🙏.

I've commented out the OPENAI_API_KEY for now to be sure it will use the AZURE_OPENAI_API_KEY.

When I now try use Fabric I get the following error.

echo "What is the Capital of the Netherlands?" | fabric --stream --pattern ai
Error: 'NoneType' object has no attribute 'chat'
'NoneType' object has no attribute 'chat'

When running the following curl I just get a response:

curl "https://<instancename>.openai.azure.com/openai/deployments/chatdemo/chat/completions?api-version=2024-02-15-preview" \
  -H "Content-Type: application/json" \
  -H "api-key: <enter api key>" \
  -d "{
  \"messages\": [{\"role\":\"system\",\"content\":\"What is the capital of the Netherlands?\"}],
  \"max_tokens\": 800,
  \"temperature\": 0.7,
  \"frequency_penalty\": 0,
  \"presence_penalty\": 0,
  \"top_p\": 0.95,
  \"stop\": null
}"

image

Something still is not configured correctly.

What am I missing? Is there a way to list this model?

Added note:

  • Running this on WSL Ubuntu.

@AtheeSouhait
Copy link

@stefanstranger did you get my repo's code? because I can"t see my changes any more in the official version. Or you can see what I changed in the utils.py file and report in the repo you cloned.

@stefanstranger
Copy link

Yes I copied the raw content from 'your' utils.py file to my local repo.

@AtheeSouhait
Copy link

Not working when I use --stream but working without.
image
Is it working when you use openai and not azure Open ai (comment the AZURE_OPENAI_API_KEY of env) ?

@stefanstranger
Copy link

Tried without using --stream switch but that is also giving me the same error.

Error: 'NoneType' object has no attribute 'chat'
'NoneType' object has no attribute 'chat'

It is working when I use OpenAI but not when I use Azure OpenAI.

Very strange that I cannot get this working with Azure OpenAI.

image

@MrPewPewLaser
Copy link

MrPewPewLaser commented Jun 22, 2024

@stefanstranger I got it to work for me. The problem seems to be that his Code is far behind the original repo that requires newer package versions. So I cloned his entire repo and forced a new install of fabric using pipx install . --force

Hope it helps. :)

@stefanstranger
Copy link

Hi @MrPewPewLaser thanks for your help.

Will try your suggestions and let you know if that works.

Regards,
Stefan

@AtheeSouhait
Copy link

Thanks @MrPewPewLaser, @stefanstranger : I also re-tested : resinstallation of fabric from https://github.com/danielmiessler/fabric (cloned, put my utils.py, and continue all installation steps + add Azure environment variables). And after the installation it worked (with gpt4 model in Azure , I didn't try 3.5 or other models yet). I know it is not perfect as --stream seams not to be supported. I hope it will work for you.

@stefanstranger
Copy link

I got it to work. One more lesson learned during the setup of the Azure OpenAI configuration is that is need the Azure OpenAI deployment name and NOT the Model name in the configuration.

@AtheeSouhait
Copy link

@stefanstranger @MrPewPewLaser Great, I'm working on a dockerfile to ease the installation, setup, and the usage. I let you know.

@eugeis
Copy link
Collaborator

eugeis commented Sep 19, 2024

Azure Open AI provider is supported now.

@eugeis eugeis closed this as completed Sep 19, 2024
@josearias210
Copy link

josearias210 commented Nov 7, 2024

@stefanstranger @MrPewPewLaser @AtheeSouhait I'm trying to implement Azure OpenIA as a vendor, and I'm using the docker version.

Is there any progress on this? Is there a branch where there is a development?

I entered the container and this is the error I get, although the .env file is configured correctly

image

@AtheeSouhait
Copy link

Hi, @josearias210
If you have the "go" version of fabric, test with those environment variable & names, that are not the same as yours:
DEFAULT_VENDOR=Azure
DEFAULT_MODEL=gpt-4o
PATTERNS_LOADER_GIT_REPO_URL=https://github.com/danielmiessler/fabric.git
PATTERNS_LOADER_GIT_REPO_PATTERNS_FOLDER=patterns
AZURE_API_KEY=xxxx
AZURE_API_BASE_URL=https://xxx.openai.azure.com/
AZURE_DEPLOYMENTS=gpt-4o
YOUTUBE_API_KEY=xxx

@josearias210
Copy link

@AtheeSouhait Thanks for your reply, I made the change and I think I made some progress because now I am facing this error.

image

I don't have any pattern. It seems like a bug in Dockerfile trying to copy the patterns?

@josearias210
Copy link

josearias210 commented Nov 8, 2024

@AtheeSouhait @stefanstranger

I manually copied the files that are created /patterns into root/.config/fabric/patterns and this fixed that problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
10 participants