| 45 | |
| 46 | @app.post('/chatbot/{username}') |
| 47 | async def process_string(request: Request, username: str): |
| 48 | # Get the JSON data from the request |
| 49 | data = await request.json() |
| 50 | input_string = data.get('input_string', '') |
| 51 | llm_model = data.get('llm_model', '') # Default to 'gemma2' if not provided |
| 52 | api_key = data.get('api_key', '') |
| 53 | |
| 54 | # Process the string using the dynamically provided llm_model and api_key |
| 55 | result = await ChatBot(get_llm(llm_model, api_key), input_string) |
| 56 | |
| 57 | # Return the result as JSON |
| 58 | return JSONResponse(content={'result': result}) |
| 59 | |
| 60 | |
| 61 | @app.post('/run/{username}') |