Code Monkey home page Code Monkey logo

Comments (14)

zzstoatzz avatar zzstoatzz commented on June 3, 2024 1

@lostmygithubaccount that's a good callout, thanks - we'll get an azure setup guide added in soon as we can

from marvin.

zzstoatzz avatar zzstoatzz commented on June 3, 2024 1

@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.

sdeep27 avatar sdeep27 commented on June 3, 2024

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.

zzstoatzz avatar zzstoatzz commented on June 3, 2024

@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.

lostmygithubaccount avatar lostmygithubaccount commented on June 3, 2024

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.

zzstoatzz avatar zzstoatzz commented on June 3, 2024

@lostmygithubaccount - ah so we look for dotenv stuff in ~/.marvin/.env, e.g.

(marvin) pad-2 :: src/open-source/marvinmain›
» 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.

lostmygithubaccount avatar lostmygithubaccount commented on June 3, 2024

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.

sdeep27 avatar sdeep27 commented on June 3, 2024

@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?

@zzstoatzz
I explicitly set it while testing, something like this
client = OpenAI(api_key = credentials['open_ai'])

from marvin.

sdeep27 avatar sdeep27 commented on June 3, 2024

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.

zzstoatzz avatar zzstoatzz commented on June 3, 2024

@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.

sdeep27 avatar sdeep27 commented on June 3, 2024

@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.

lostmygithubaccount avatar lostmygithubaccount commented on June 3, 2024

@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.

zzstoatzz avatar zzstoatzz commented on June 3, 2024

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.

lostmygithubaccount avatar lostmygithubaccount commented on June 3, 2024

yep! I'll open more specific issues with Azure as I run into them

from marvin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.