GithubHelp home page GithubHelp logo

FastAPI deployment about uptrain HOT 2 CLOSED

HasnainKhanNiazi avatar HasnainKhanNiazi commented on July 18, 2024
FastAPI deployment

from uptrain.

Comments (2)

HasnainKhanNiazi avatar HasnainKhanNiazi commented on July 18, 2024 1

@ashish-1600 Thanks, that was the issue indeed.

from uptrain.

ashish-1600 avatar ashish-1600 commented on July 18, 2024

Hi @HasnainKhanNiazi ,
Thanks for raising this issue.

I have figured out a way to get this working in your use-case.
I am using uvicorn as my ASGI web server framework. In uvicorn, we have to set the event loop as 'asyncio'.

I am attaching the code for your reference.

@app.get("/")
async def read_root():
    return {"message": "Welcome to the LLM Evaluation API"}

@app.post("/evaluate/hallucination", response_model=EvaluationResponse)
async def hallucination_detect():
    try:
        data = [
            {
                "question": "Hello",
                "context": "Hello",
                "response": "Hello",
            }
        ]
        result = eval_llm.evaluate(
            data=data,
            checks=[Evals.FACTUAL_ACCURACY],
        )
        print(result)
        return EvaluationResponse(result=result)
    except Exception as e:
        return EvaluationResponse(result={}, error=str(e))
    

if __name__ == "__main__":
    uvicorn.run("app:app", host="0.0.0.0", port=4300, loop='asyncio')

You don't have to make any changes in the EvalLLM. Let me know if it works for you. :)

from uptrain.

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.