OpenInterpreter / open-interpreter

A natural language interface for computers
http://openinterpreter.com/
GNU Affero General Public License v3.0
50.54k stars 4.4k forks source link

Provides a freely managed context interface #1296

Closed bincooo closed 3 weeks ago

bincooo commented 3 weeks ago

Is your feature request related to a problem? Please describe.

Can the --server parameter provide a context parameter passed in by the user?

for example:

    @app.post("/chat")
    async def stream_endpoint(request: Request) -> Response:
        data = await request.json()
        interpreter.messages = data["previousMessages"]
        async def event_stream() -> Generator[str, None, None]:
            for response in interpreter.chat(message=data["message"], stream=True):
                chunk = "data: %s\n\n" % json.dumps(response)
                yield chunk
            yield "data: [DONE]"

        return StreamingResponse(event_stream(), media_type="text/event-stream")

I am not clear how to modify and run.

Describe the solution you'd like

-

Describe alternatives you've considered

No response

Additional context

No response