Comments (14)
@lostmygithubaccount that's a good callout, thanks - we'll get an azure setup guide added in soon as we can
from marvin.
@sdeep27 sorry yep that's on us, right now the docs are showing marvin 2.x which is confusing because only the pre-release is available on pip - full release coming soon.
I've just updated the quickstart / settings docs in that PR to make it clearer - thanks for the callout!
from marvin.
Using prerelease v2.0.1a1, got this same error with regular OpenAI (not Azure) and using this copied example from docs. :
@ai_fn(client=client)
def sentiment_list(texts: list[str]) -> list[float]:
"""
Given a list of texts
, returns a list of numbers between 1 (positive) and
-1 (negative) indicating their respective sentiment scores.
"""
sentiment_list(
[
"That was surprisingly easy!",
"Oh no, not again.",
]
)
from marvin.
@lostmygithubaccount do you get the same error if you set OPENAI_API_KEY
instead of AZURE_OPENAI_API_KEY
?
@sdeep27 - how have you set your api key?
from marvin.
yes same error -- tested by just copying AZURE_OPENAI_API_KEY
as OPENAI_API_KEY
in an additional line in my .env
file and re-running
from marvin.
@lostmygithubaccount - ah so we look for dotenv stuff in ~/.marvin/.env
, e.g.
(marvin) pad-2 :: src/open-source/marvin ‹main›
» cat ~/.marvin/.env | rg OPENAI
MARVIN_OPENAI_API_KEY=sk-xxx
MARVIN_OPENAI_ORGANIZATION=org-xxx
also my bad, the way the pydantic settings work, I would prefix the env var with MARVIN_
if you set OPENAI_API_KEY
somewhere global like your ~/.zshrc
, it should get picked up as well
from marvin.
I got a step farther by copying my .env
file to ~/.marvin
and prefixing each line with MARVIN_
, then hit this (another error I think I saw in a different attempt):
NotFoundError: Error code: 404 - {'error': {'code': 'DeploymentNotFound', 'message': 'The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.'}}
I'm assuming I need to set a separate deployment environment variable from the client instantiation? regardless of what's needed right now, would appreciate a clear setup guide for getting Azure OpenAI to work w/ v2! would love to upgrade, have been stuck on v1.3.0
from marvin.
@lostmygithubaccount do you get the same error if you set
OPENAI_API_KEY
instead ofAZURE_OPENAI_API_KEY
?@sdeep27 - how have you set your api key?
@zzstoatzz
I explicitly set it while testing, something like this
client = OpenAI(api_key = credentials['open_ai'])
from marvin.
Here's the full code:
from marvin import ai_model, ai_fn, ai_classifier
from pydantic import BaseModel, Field
from openai import OpenAI
oai_client = OpenAI(api_key=SECRETS['openai1'])
@ai_fn(client=oai_client)
def sentiment_list(texts: list[str]) -> list[float]:
"""
Given a list of `texts`, returns a list of numbers between 1 (positive) and
-1 (negative) indicating their respective sentiment scores.
"""
sentiment_list(
[
"That was surprisingly easy!",
"Oh no, not again.",
]
)
returns:
AttributeError: 'NoneType' object has no attribute 'get_secret_value'
from marvin.
@sdeep27 if you're not using azure, you should just be able to set MARVIN_OPENAI_API_KEY
in ~/.marvin/.env
and not have to pass a client to ai_fn
although it does seem we should fail more gracefully here so I've opened #707
from marvin.
@zzstoatzz thanks for the quick responses! it is working now. There is some confusion because the website docs seem to be using the v2 syntax with no mention that it is not the default version installed on pip. Then to compound, the website docs have us passing the openAI client with the key rather than mentioning setting the marvin env variable.
from marvin.
@zzstoatzz can you confirm Azure is supported right now in v2 and which environment variables need to be set? I'm not seeing much with "Azure" in the codebase and can't figure it out, but things seemed to have changed from v1
if I can get that working I'd be happy to help PR a setup guide for Azure OpenAI -- for now going to play around w/ v2 on a regular OpenAI account
from marvin.
hi @lostmygithubaccount - forgive me I feel like we've chatted on different issues at this point about this, but do you think we can close this issue?
i've been able to test against azure myself recently and I'm not having any troubles using these env vars
from marvin.
yep! I'll open more specific issues with Azure as I run into them
from marvin.
Related Issues (20)
- Dependency error with `openai` HOT 2
- AI Model for complex structures HOT 5
- test
- Broken import in Marvin from OpenAI client version 1.8.0 HOT 1
- Azure OpenAI doesn't work with `.env` in project-specific directories HOT 1
- Update README Only After New Version is Released on PyPI HOT 2
- test webhook HOT 1
- ImportError: cannot import name 'BaseMessage' from 'marvin.types'
- add configurable retries that swap `model_kwargs` HOT 2
- Format string for "created_at" in assistant not valid HOT 1
- Async model/cast/extract calls HOT 3
- support speech to text
- add collection docs to marvin bot index
- API key required even when using local language models HOT 1
- Defining ai_fn at runtime HOT 6
- Marvin install fails HOT 2
- Running into tiktoken issue with Azure OpenAI endpoint HOT 3
- Marvin Speak Language Selection HOT 1
- [Azure OpenAI] Error when deployment name != model name HOT 3
- Homepage (https://www.prefect.io/marvin) "Learn More" CTAs return 404
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marvin.