finic-ai / doctran

MIT License
491 stars 42 forks source link

Support for Azure OpenAI #13

Open ghbacct opened 1 year ago

ghbacct commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 12 months ago

@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 commented 12 months ago

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