Put start agent/call at localhost root. Before you had to read in the docs to go to /start, or /start_call or /start_bot. Which isn't mentioned in the console output, and is inconsistent, adding friction to learning the codebase
This commit is contained in:
@@ -27,7 +27,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a chatbot session.
|
Then, visit `http://localhost:7860/` in your browser to start a chatbot session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a chatbot session.
|
Then, visit `http://localhost:7860/` in your browser to start a chatbot session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
|
|||||||
@@ -34,6 +34,6 @@ Note: you can do this manually via the fly.io dashboard under the "secrets" sub-
|
|||||||
|
|
||||||
Send a post request to your running fly.io instance:
|
Send a post request to your running fly.io instance:
|
||||||
|
|
||||||
`curl --location --request POST 'https://YOUR_FLY_APP_NAME/start_bot'`
|
`curl --location --request POST 'https://YOUR_FLY_APP_NAME/'`
|
||||||
|
|
||||||
This request will wait until the machine enters into a `starting` state, before returning the a room URL and token to join.
|
This request will wait until the machine enters into a `starting` state, before returning the a room URL and token to join.
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ async def spawn_fly_machine(room_url: str, token: str):
|
|||||||
print(f"Machine joined room: {room_url}")
|
print(f"Machine joined room: {room_url}")
|
||||||
|
|
||||||
|
|
||||||
@app.post("/start_bot")
|
@app.post("/")
|
||||||
async def start_bot(request: Request) -> JSONResponse:
|
async def start_bot(request: Request) -> JSONResponse:
|
||||||
try:
|
try:
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a chatbot
|
Then, visit `http://localhost:7860/` in your browser to start a chatbot
|
||||||
session.
|
session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
@@ -41,4 +41,4 @@ docker build -t moonbot -f Dockerfile.intel .
|
|||||||
docker run --env-file .env -p 7860:7860 --device /dev/dri moonbot
|
docker run --env-file .env -p 7860:7860 --device /dev/dri moonbot
|
||||||
```
|
```
|
||||||
|
|
||||||
You can try to visit `http://localhost:7860/start` again.
|
You can try to visit `http://localhost:7860/` again.
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a chatbot session.
|
Then, visit `http://localhost:7860/` in your browser to start a chatbot session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
@@ -128,7 +128,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument("--reload", action="store_true", help="Reload code on change")
|
parser.add_argument("--reload", action="store_true", help="Reload code on change")
|
||||||
|
|
||||||
config = parser.parse_args()
|
config = parser.parse_args()
|
||||||
print(f"to join a test room, visit http://localhost:{config.port}/start")
|
print(f"to join a test room, visit http://localhost:{config.port}/")
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
"server:app",
|
"server:app",
|
||||||
host=config.host,
|
host=config.host,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a chatbot session.
|
Then, visit `http://localhost:7860/` in your browser to start a chatbot session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default function Call() {
|
|||||||
|
|
||||||
// Create a new room for the story session
|
// Create a new room for the story session
|
||||||
try {
|
try {
|
||||||
const response = await fetch("/start_bot", {
|
const response = await fetch("/", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ STATIC_DIR = "frontend/out"
|
|||||||
app.mount("/static", StaticFiles(directory=STATIC_DIR, html=True), name="static")
|
app.mount("/static", StaticFiles(directory=STATIC_DIR, html=True), name="static")
|
||||||
|
|
||||||
|
|
||||||
@app.post("/start_bot")
|
@app.post("/")
|
||||||
async def start_bot(request: Request) -> JSONResponse:
|
async def start_bot(request: Request) -> JSONResponse:
|
||||||
if os.getenv("ENV", "dev") == "production":
|
if os.getenv("ENV", "dev") == "production":
|
||||||
# Only allow requests from the specified domain
|
# Only allow requests from the specified domain
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ cp env.example .env # and add your credentials
|
|||||||
python server.py
|
python server.py
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, visit `http://localhost:7860/start` in your browser to start a translatorbot session.
|
Then, visit `http://localhost:7860/` in your browser to start a translatorbot session.
|
||||||
|
|
||||||
## Build and test the Docker image
|
## Build and test the Docker image
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/start")
|
@app.get("/")
|
||||||
async def start_agent(request: Request):
|
async def start_agent(request: Request):
|
||||||
print(f"!!! Creating room")
|
print(f"!!! Creating room")
|
||||||
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
room = await daily_helpers["rest"].create_room(DailyRoomParams())
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ This project is a FastAPI-based chatbot that integrates with Twilio to handle We
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. **Update the Twilio Webhook**:
|
2. **Update the Twilio Webhook**:
|
||||||
Copy the ngrok URL and update your Twilio phone number webhook URL to `http://<ngrok_url>/start_call`.
|
Copy the ngrok URL and update your Twilio phone number webhook URL to `http://<ngrok_url>/`.
|
||||||
|
|
||||||
3. **Update streams.xml**:
|
3. **Update streams.xml**:
|
||||||
Copy the ngrok URL and update templates/streams.xml with `wss://<ngrok_url>/ws`.
|
Copy the ngrok URL and update templates/streams.xml with `wss://<ngrok_url>/ws`.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ app.add_middleware(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/start_call")
|
@app.post("/")
|
||||||
async def start_call():
|
async def start_call():
|
||||||
print("POST TwiML")
|
print("POST TwiML")
|
||||||
return HTMLResponse(content=open("templates/streams.xml").read(), media_type="application/xml")
|
return HTMLResponse(content=open("templates/streams.xml").read(), media_type="application/xml")
|
||||||
|
|||||||
Reference in New Issue
Block a user