diff --git a/.gitignore b/.gitignore
index a6dd346..5997da4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ node_modules/
/playwright-report/
/blob-report/
/playwright/.cache/
+.env
\ No newline at end of file
diff --git a/backend/api/routes/chat.py b/backend/api/routes/chat.py
index 2a2dab5..81a9135 100644
--- a/backend/api/routes/chat.py
+++ b/backend/api/routes/chat.py
@@ -4,7 +4,7 @@
import json
from typing import Dict, Optional
from constants import SPEEKERS
-from utils import combine_audio, generate_dialogue, generate_podcast_info, generate_podcast_summary, get_pdf_text
+from utils import combine_audio, generate_dialogue, generate_podcast_info, generate_podcast_summary, get_link_text, get_pdf_text
router = APIRouter()
@@ -12,12 +12,19 @@
async def generate_transcript(
pdfFile: Optional[UploadFile] = File(None),
textInput: str = Form(...),
+ mode: str = Form(...),
+ url: Optional[str] = Form(None),
tone: str = Form(...),
duration: str = Form(...),
language: str = Form(...),
):
- pdfContent = await get_pdf_text(pdfFile)
+ pdfContent =""
+ if mode=='pdf':
+ pdfContent = await get_pdf_text(pdfFile)
+ else:
+ linkData = get_link_text(url)
+ pdfContent = linkData['text']
new_text = pdfContent
return StreamingResponse(generate_dialogue(new_text,textInput, tone, duration, language), media_type="application/json")
@@ -31,6 +38,11 @@ def test():
def speeker():
return JSONResponse(content=SPEEKERS)
+@router.get("/jina")
+def jina():
+ result = get_link_text("https://ui.shadcn.com/docs/components/select")
+ return JSONResponse(content=result)
+
@router.post("/summarize")
async def get_summary(
@@ -38,9 +50,16 @@ async def get_summary(
tone: str = Form(...),
duration: str = Form(...),
language: str = Form(...),
+ mode: str = Form(...),
+ url: Optional[str] = Form(None),
pdfFile: Optional[UploadFile] = File(None)
):
- pdfContent = await get_pdf_text(pdfFile)
+ pdfContent =""
+ if mode=='pdf':
+ pdfContent = await get_pdf_text(pdfFile)
+ else:
+ linkData = get_link_text(url)
+ pdfContent = linkData['text']
new_text = pdfContent
return StreamingResponse(
generate_podcast_summary(
@@ -59,9 +78,17 @@ async def get_pod_info(
tone: str = Form(...),
duration: str = Form(...),
language: str = Form(...),
+ mode: str = Form(...),
+ url: Optional[str] = Form(None),
pdfFile: Optional[UploadFile] = File(None)
):
- pdfContent = await get_pdf_text(pdfFile)
+ pdfContent =""
+ if mode=='pdf':
+ pdfContent = await get_pdf_text(pdfFile)
+ else:
+ linkData = get_link_text(url)
+ pdfContent = linkData['text']
+
new_text = pdfContent[:100]
return StreamingResponse(generate_podcast_info(new_text, textInput, tone, duration, language), media_type="application/json")
diff --git a/backend/main.py b/backend/main.py
index 2395825..b9641f3 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -16,7 +16,7 @@
# 添加CORS中间件
app.add_middleware(
CORSMiddleware,
- allow_origins=["https://ai.podcastlm.fun/"],
+ allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
diff --git a/backend/utils.py b/backend/utils.py
index f50fafc..c0b26fc 100644
--- a/backend/utils.py
+++ b/backend/utils.py
@@ -5,10 +5,10 @@
import re
import time
import hashlib
-
from typing import Any, Dict, Generator
import uuid
from openai import OpenAI
+import requests
from fishaudio import fishaudio_tts
from prompts import LANGUAGE_MODIFIER, LENGTH_MODIFIERS, PODCAST_INFO_PROMPT, QUESTION_MODIFIER, SUMMARY_INFO_PROMPT, SYSTEM_PROMPT, TONE_MODIFIER
import json
@@ -254,6 +254,16 @@ def clear_pdf_cache():
global pdf_cache
pdf_cache.clear()
+def get_link_text(url: str):
+ """ 通过jina.ai 抓取url内容 """
+ url = f"https://r.jina.ai/{url}"
+ headers = {}
+ headers['Authorization'] = 'Bearer jina_c1759c7f49e14ced990ac7776800dc44ShJNTXBCizzwjE7IMFYJ6LD960cG'
+ headers['Accept'] = 'application/json'
+ headers['X-Return-Format'] = 'text'
+ response = requests.get(url, headers=headers)
+ return response.json()['data']
+
async def get_pdf_text(pdf_file: UploadFile):
text = ""
print(pdf_file)
diff --git a/frontend/.env.template b/frontend/.env.template
new file mode 100644
index 0000000..1a144f6
--- /dev/null
+++ b/frontend/.env.template
@@ -0,0 +1,2 @@
+BASE_URL=
+HOST_URL=
\ No newline at end of file
diff --git a/frontend/package.json b/frontend/package.json
index 3d60828..1679d61 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -17,6 +17,7 @@
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.1",
+ "@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"axios": "^1.7.7",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 2dc25e9..4801a01 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -29,6 +29,9 @@ importers:
'@radix-ui/react-tabs':
specifier: ^1.1.1
version: 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-toast':
+ specifier: ^1.2.2
+ version: 1.2.2(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@radix-ui/react-toggle':
specifier: ^1.1.0
version: 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
@@ -759,6 +762,19 @@ packages:
'@types/react-dom':
optional: true
+ '@radix-ui/react-toast@1.2.2':
+ resolution: {integrity: sha512-Z6pqSzmAP/bFJoqMAston4eSNa+ud44NSZTiZUmUen+IOZ5nBY8kzuU5WDBVyFXPtcW6yUalOHsxM/BP6Sv8ww==}
+ peerDependencies:
+ '@types/react': '*'
+ '@types/react-dom': '*'
+ react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
'@radix-ui/react-toggle-group@1.1.0':
resolution: {integrity: sha512-PpTJV68dZU2oqqgq75Uzto5o/XfOVgkrJ9rulVmfTKxWp3HfUjHE6CP/WLRR4AzPX9HWxw7vFow2me85Yu+Naw==}
peerDependencies:
@@ -3029,6 +3045,26 @@ snapshots:
'@types/react': 18.3.11
'@types/react-dom': 18.3.0
+ '@radix-ui/react-toast@1.2.2(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
+ dependencies:
+ '@radix-ui/primitive': 1.1.0
+ '@radix-ui/react-collection': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-compose-refs': 1.1.0(@types/react@18.3.11)(react@18.3.1)
+ '@radix-ui/react-context': 1.1.1(@types/react@18.3.11)(react@18.3.1)
+ '@radix-ui/react-dismissable-layer': 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-portal': 1.1.2(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-presence': 1.1.1(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-primitive': 2.0.0(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ '@radix-ui/react-use-callback-ref': 1.1.0(@types/react@18.3.11)(react@18.3.1)
+ '@radix-ui/react-use-controllable-state': 1.1.0(@types/react@18.3.11)(react@18.3.1)
+ '@radix-ui/react-use-layout-effect': 1.1.0(@types/react@18.3.11)(react@18.3.1)
+ '@radix-ui/react-visually-hidden': 1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ react: 18.3.1
+ react-dom: 18.3.1(react@18.3.1)
+ optionalDependencies:
+ '@types/react': 18.3.11
+ '@types/react-dom': 18.3.0
+
'@radix-ui/react-toggle-group@1.1.0(@types/react-dom@18.3.0)(@types/react@18.3.11)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@radix-ui/primitive': 1.1.0
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index ecfb0c3..dd8cb7d 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -5,6 +5,7 @@ import { useJsonData } from "./hooks/useJsonData";
import { useStreamText } from './hooks/useStreamText';
import { BASE_URL } from "./lib/constant";
import MobileMenu from "./components/mobile-menu";
+import { Toaster } from "@/components/ui/toaster"
function App() {
const [isGenerating, setIsGenerating] = useState(false);
@@ -37,6 +38,7 @@ function App() {
}
return (
+