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

Support for Azure OpenAI #13

Open
ghbacct opened this issue Nov 20, 2023 · 4 comments
Open

Support for Azure OpenAI #13

ghbacct opened this issue Nov 20, 2023 · 4 comments

Comments

@ghbacct
Copy link

ghbacct commented Nov 20, 2023

There is a previous issue that seems to have added this functionality, however it's not clear to me how I can use it.

How can I use Doctran with Azure OpenAI models?

@yb-sid
Copy link

yb-sid commented Nov 29, 2023

I'm facing similar issue , I would like to use doctran with Azure open AI ,

I've got access to following environment variables :
OPENAI_EMBEDDING_API_KEY
OPENAI_CHAT_API_KEY
OPENAI_CHAT_MODEL_NAMES

OPENAI_CHAT_API_BASE_URL
OPENAI_EMBEDDING_API_BASE_URL

OPENAI_EMBEDDING_VERSION
OPENAI_CHAT_VERSION

but not sure how to use them with doctran

@aroffe99
Copy link

I was able to use doctran for azure with this code

from doctran import Doctran
import os

# This is the Azure OpenAI Endpoint
os.environ["OPENAI_API_BASE"] = "https://{YOUR_RESOURCE_NAME}.openai.azure.com/"
os.environ["OPENAI_API_VERSION"] = <API_VERSION>

doctran = Doctran(
    openai_api_key=<AZURE_OPENAI_API_KEY>,
    openai_deployment_id=<AZURE_OPENAI_DEPLOYMENT_ID>,
)

document = doctran.parse(
    content="",
    content_type="text"
)

@yb-sid
Copy link

yb-sid commented Dec 1, 2023

@aroffe99
Thanks for your inputs. I tied out your code with few modification.

os.environ["OPENAI_API_BASE"] = OPENAI_CHAT_API_BASE_URL
os.environ["OPENAI_API_VERSION"] = OPENAI_CHAT_VERSION
os.environ["OPENAI_API_TYPE"] = "azure"
doctran = Doctran(
    openai_api_key=OPENAI_CHAT_API_KEY,
    openai_deployment_id=DEPLOYMENT_ID
)

document = doctran.parse(
    content=STRING_CONTENT,
    content_type="text"
)

but when I call interrogate :
interrogate_doc = await document.interrogate().execute()

I get error ::
Exception: Error executing transformation (<Transformation.interrogate: 'DocumentInterrogator'>, {}): OpenAI function call failed: Unrecognized request argument supplied: functions

Not enough information for me to go further , did you face such error ?

@yb-sid
Copy link

yb-sid commented Dec 1, 2023

please ignore my earlier comment , I had a problem with my version which was using older chat-completion api

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