Coder Social home page Coder Social logo

copilot_share's Issues

关于本项目使用后提出的建议

关于代理请求这块提个愚见

  1. 关于封装的代理请求proxy.py中,虽然定义了async函数,但没见到函数中有异步操作。此外,所使用的请求库“requests” 也是同步的,我认为这会导致出现阻塞事件循环,建议可以改用httpx 等异步HTTP客户端库。

  2. 在app.py文件中,使用了await将异步函数转换成了同步导致了chat的结果是一次性返回的,这样写的话很容易在请求中将内容一次性加载到内存中,不利于多用户使用以及持续的数据流传输。其次类似GPT等chat应用基本上都是以流的方式返回,也就是一部分一部分打印出来的效果。

修改建议

  • 在请求时使用StreamingResponse 流的方式返回,在请求时可以有效的减少内存的使用并提供更快的响应时间。

本人也对python也不熟。正好在搞一个GPT4的项目,试着用GPT4改了一下不知道对不对哈哈哈哈

// 
import httpx
from starlette.responses import StreamingResponse

async def proxy_request(request: Request, target_url: str) -> StreamingResponse:
    """
    Send a proxy request to the target URL.

    :param request: The request object to proxy.
    :param target_url: The target URL to proxy the request to.
    :return: A streaming response from the target server.
    """
    request_headers = dict(request.headers)
    request_headers.pop("Host", None)
    request_body = await request.body()
    request_method = request.method

    async with httpx.AsyncClient() as client:
        resp = await client.request(
            request_method,
            target_url,
            headers=request_headers,
            data=request_body,
            stream=True
        )

        return StreamingResponse(
            resp.aiter_bytes(),
            headers=resp.headers,
            status_code=resp.status_code
        )

copilot chat没有生效啊

安装vscode.sh里面sed命令,手动修改配置,chat并不能生效啊,请问这个脚本现在还适用 ?

copilot to gpt4 model

问一下下面的修改系统提示怎么做到的,怎么问都是说是ai编程助手
我想问点不是编程的问题都问不了
大佬,指点一下啊
1

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.