gpt4free
gpt4free copied to clipboard
ChatCompletion returns html
response = g4f.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[{"role": "user", "content": "hello"}],
stream=True,
)
for message in response:
print(message, flush=True)
returns:
# python test.py
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"
/>
<meta content="yes" name="apple-mobile-web-app-capable" />
<title></title>
<link rel="apple-touch-icon" href="/apple-touch.ico" />
<link rel="stylesheet" href="/lib/katex/katex.min.css" />
<link rel="stylesheet" href="/lib/highlight/default.min.css" />
<script src="/lib/highlight/highlight.min.js" defer></script>
<script src="/config/index.js" defer></script>
<script type="module" crossorigin src="/assets/index-fd7ef130.js"></script>
<link rel="stylesheet" href="/assets/index-ac7a8d57.css">
<script type="module">import.meta.url;import("_").catch(()=>1);async function* g(){};if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script>
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
</head>
<body class="dark:bg-[#111114]">
<div id="app">
<style>
.loading-wrap {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.balls {
width: 4em;
display: flex;
flex-flow: row nowrap;
align-items: center;
justify-content: space-between;
}
.balls div {
width: 0.8em;
height: 0.8em;
border-radius: 50%;
background-color: #4b9e5f;
}
.balls div:nth-of-type(1) {
transform: translateX(-100%);
animation: left-swing 0.5s ease-in alternate infinite;
}
.balls div:nth-of-type(3) {
transform: translateX(-95%);
animation: right-swing 0.5s ease-out alternate infinite;
}
@keyframes left-swing {
50%,
100% {
transform: translateX(95%);
}
}
@keyframes right-swing {
50% {
transform: translateX(-95%);
}
100% {
transform: translateX(100%);
}
}
@media (prefers-color-scheme: dark) {
body {
background: #121212;
}
}
</style>
<div class="loading-wrap">
<div class="balls">
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
<script nomodule crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-a34bcd73.js"></script>
<script nomodule crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-eead6c44.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
</body>
</html>
same question:
I also have this bug in the g4f library Fixed by regenerating when DOCTYPE is in the response
I also have this bug in the g4f library Fixed by regenerating when DOCTYPE is in the response
@danyl756 but it responds to all requests like this
Did you know which provider returns the HTML? You can try use a other provider.
Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.