Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case sensitive bug in compilation on linux #3

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
516fc08
Create replicate_concurrency.py
maraoai Mar 24, 2024
f2d3487
Add todo
nyacg Mar 24, 2024
982603f
Generate images with replicate on selfie upload
nyacg Mar 24, 2024
7be977c
Use images in chat window
nyacg Mar 24, 2024
1294510
Add some todos
nyacg Mar 24, 2024
7b413c8
added model exploration
Mar 24, 2024
99c1709
reply with less than 3 sentences
Mar 24, 2024
426ae89
added app
Mar 24, 2024
28ac188
video, auth and requirements
mlgraham Mar 24, 2024
2affafd
added the get_response that decides who talks back and what to say
Mar 24, 2024
a6c3951
fix long running history
Mar 24, 2024
7f8a067
py: clean up env var loading, make more clear if D_ID is missing
tmc Mar 24, 2024
c8ac96b
env vars
mlgraham Mar 24, 2024
95db99d
generate prompt for system of each parts
Mar 24, 2024
9277617
tweak app.py
Mar 24, 2024
227bbc7
set root page back to bootstrap content (see /chat)
tmc Mar 24, 2024
6d20ea7
added a loading screen
Mar 24, 2024
f697973
add info about each on screen
Mar 24, 2024
df7adb5
added example test
Mar 24, 2024
8d1c5ec
d-id: set contents of DIDVideoStream to previous state
tmc Mar 24, 2024
12554dc
testing: add routes for exercising video components
tmc Mar 24, 2024
1ccbed1
chat logs
mlgraham Mar 24, 2024
849677c
Revert "d-id: set contents of DIDVideoStream to previous state"
tmc Mar 24, 2024
34c44fd
did: small fixups
tmc Mar 24, 2024
72cbf3a
components: Add SpeechToText component
tmc Mar 24, 2024
b9bd771
add SpeechToText to /chat
tmc Mar 24, 2024
4a0f554
added message bubbles
Mar 24, 2024
661dd36
added pnpm lock
Mar 24, 2024
9bfdb80
py: use pip-tools to compile requirements
tmc Mar 24, 2024
b32c670
add sidebar logs UI
Mar 24, 2024
7fa6d7b
add responder in history
Mar 24, 2024
f822b84
rather than using a form, use onclick
Mar 24, 2024
a4ff0a9
mr-1
Mar 24, 2024
bf91147
fix app.py to add back instructor
Mar 24, 2024
f0e7eb4
added requirements.in for instructor
Mar 24, 2024
45eb11f
De-gender and update image prompts
nyacg Mar 24, 2024
2b29fe6
Save images to a given ID
nyacg Mar 24, 2024
018e3d4
Some styling
nyacg Mar 24, 2024
9ee091a
added video creation from did to the chat/page.js
Mar 24, 2024
c4213e9
Go from start to chat
nyacg Mar 24, 2024
fbd553a
Merge remote-tracking branch 'origin/main'
nyacg Mar 24, 2024
f4666df
Remove hardcoded rant true
nyacg Mar 24, 2024
2385476
Tidy even more
nyacg Mar 24, 2024
726ba7f
Update replicate_concurrency.py
maraoai Mar 24, 2024
ac1abc0
Fix array output from replicate bug
nyacg Mar 24, 2024
49a3692
Tidy
nyacg Mar 24, 2024
6baa46f
Fix loading not disappearing
nyacg Mar 24, 2024
fd055c3
Styling
nyacg Mar 24, 2024
eee22d2
Styling
nyacg Mar 24, 2024
a95e784
Get videos to play 🎉
nyacg Mar 24, 2024
85808d7
py: hint in example env, regen reqs
tmc Mar 24, 2024
929882d
Generate the system prompt
nyacg Mar 24, 2024
0a13be4
Merge remote-tracking branch 'origin/main'
nyacg Mar 24, 2024
19b5159
british accent
Mar 24, 2024
8d1b6f5
Caching of system prompts
nyacg Mar 24, 2024
cf52cb1
Merge remote-tracking branch 'origin/main'
nyacg Mar 24, 2024
ec10424
use react router and turned off react strict mode
Mar 30, 2024
263eca8
readme
Mar 31, 2024
47e02a1
readme
Mar 31, 2024
e6f7f9d
fix social
Mar 31, 2024
ef29cbb
fix README
Mar 31, 2024
8d15d65
upload social
Mar 31, 2024
cba3711
Video
Mar 31, 2024
b28126f
README update
Mar 31, 2024
80bcd0f
README update
Mar 31, 2024
d127441
Update README.md
hackgoofer Mar 31, 2024
a54aa1a
add license
Apr 1, 2024
3d3f6b1
case sensitive bug in compilation on linux
ninjaa Apr 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 AgentOps-AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<p align="center">
<img src="https://raw.githubusercontent.com/hackgoofer/IFS.AI/ef29cbb223b86d12d2d497057601a00f92a7cfb0/ifs.ai/public/social.png?token=GHSAT0AAAAAACFT7GCPZQCBJJOQMNYU66IOZQI4DBA" height="300" alt="IFS.AI Logo"/>
</p>

<p align="center">
<em> Embrace every part of you with through conversation. Inspired by Internal Family System Therapy </em>
</p>

## What is Internal Family System Therapy
IFS is a transformative tool that conceives of every human being as a system of protective and wounded inner parts led by a core Self. We believe the mind is naturally multiple and that is a good thing. Just like members of a family, inner parts are forced from their valuable states into extreme roles within us. Self is in everyone. It can’t be damaged. It knows how to heal.

More Resources about IFS:
- [Podcast](https://mormondiscussionpodcast.org/2023/06/internal-family-systems-therapy-talking-to-your-parts-almost-awakened-156/)
- [Video](https://youtu.be/DdZZ7sTX840)


## Getting Started :rocket:

### Frontend:
- Go inside ifs.ai folder
- Copy .env.example to .env
- Fill in .env
- Required Services are: replicate, uploadthing

### Backend:
- Go inside ifs.py folder
- install relevant requirements, see backend README
- Copy .env.example to .env
- Backend Required Services are: De-ID, Mistral, OpenAI

<p align="center">
<img src="https://raw.githubusercontent.com/hackgoofer/IFS.AI/ef29cbb223b86d12d2d497057601a00f92a7cfb0/ifs.ai/public/social.png?token=GHSAT0AAAAAACFT7GCPZQCBJJOQMNYU66IOZQI4DBA" height="300" alt="IFS.AI Logo"/>
</p>

## ✨ Demo
For the best demo experience, we will be launching a hosted version SOON. Stay Tuned.

5 changes: 4 additions & 1 deletion ifs.ai/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# uploadthing API key, get yours here: https://uploadthing.com/dashboard/
UPLOADTHING_SECRET=
UPLOADTHING_APP_ID=
UPLOADTHING_APP_ID=

# Replicate token, get yours here https://replicate.com/account/api-tokens
REPLICATE_API_TOKEN=
1 change: 1 addition & 0 deletions ifs.ai/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/.pnp
.pnp.js
.yarn/install-state.gz
.env

# testing
/coverage
Expand Down
60 changes: 40 additions & 20 deletions ifs.ai/app/DIDVideoStream.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
import { useEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { useToast } from "@/components/ui/use-toast";

const URL = "http://localhost:5000";

/**
* DIDVideoStream component
* This component handles video streaming using a direct URL.
* It fetches a video from a specified URL and displays it in a video element.
*
* Props:
* - avatarUrl: string - The URL of the avatar image to be displayed as a poster.
* - utterance: string - The text utterance to be sent to the server for generating the video.
*/
export default function DIDVideoStream({ avatarUrl, utterance }: { avatarUrl: string; utterance: string }) {
const videoElement = useRef<HTMLVideoElement>(null);
const [isFetching, setIsFetching] = useState(false);
// call client.say when utterance changes or when peer connection is 'connected'
const { toast } = useToast();

useEffect(() => {
console.log("utterance or avatars changed");
const doSay = async () => {
console.log("utterance or avatars changed");
setIsFetching(true);
// POST image_url and text to URL
const result = await fetch(`${URL}/create_talk`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ image_url: avatarUrl, text: utterance }),
});
setIsFetching(false);
const data = await result;
const text = await data.text();
console.log("setting video src to", text);
// TODO: get this working
videoElement?.current?.setAttribute("src", text);
try {
setIsFetching(true);

const response = await fetch(`${URL}/create_talk`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ image_url: avatarUrl, text: utterance }),
});

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.text();
console.log("Setting video src to", data);
videoElement?.current?.setAttribute("src", data);
} catch (error) {
console.error("Error fetching video:", error);
toast({ title: "Error fetching video", description: JSON.stringify(error) });
// Display an error message to the user or handle the error gracefully
} finally {
setIsFetching(false);
}
};

doSay();
}, [utterance, avatarUrl]);
}, [utterance, avatarUrl, toast]);

return (
<div>
<div className="video-wrapper">
<div>
<video poster={avatarUrl} width="400" height="400" autoPlay></video>
<video ref={videoElement} poster={avatarUrl} width="400" height="400" autoPlay></video>
</div>
</div>
<br />
Expand Down
2 changes: 1 addition & 1 deletion ifs.ai/app/DIDWebRTCVideoStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { initializeStreamingClient } from "./streaming-client-api";
// import shadcn button:
import { Button } from "@/components/ui/button";

export default function DIDVideoStream({ avatarUrl, utterance }: { avatarUrl: string }) {
export default function DIDVideoStream({ avatarUrl, utterance }: { avatarUrl: string; utterance: string }) {
const videoElementRef = useRef(null);
const [iceGatheringStatusLabel, setIceGatheringStatusLabel] = useState("");
const [iceStatusLabel, setIceStatusLabel] = useState("");
Expand Down
48 changes: 47 additions & 1 deletion ifs.ai/app/api/uploadthing/core.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import { createUploadthing, type FileRouter } from "uploadthing/next";
import { UploadThingError } from "uploadthing/server";
import Replicate from "replicate";
import { PartImageUrls } from "@/app/constants";

const f = createUploadthing();

const auth = (req: Request) => ({ id: "fakeUserId" }); // Fake auth function

const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});

async function makePartImages(inputUrl: string): Promise<PartImageUrls> {
const prompts = {
manager:
"A photo of a person img upclose, facing camera, looking mature confident and controlled, professional outfit, upright posture, orderly surroundings, muted background colors, symbols of achievement, sense of discipline and responsibility",
firefighter:
"A photo of a person img upclose, facing camera, fierce expression, intense eyes, firefighter, bold outfit, fiery background colors, sense of urgency and strength",
exile:
"A photo of a child img upclose, facing camera, young and extremely vulnerable, infant, eyes filled with fear and uncertainty, tattered and worn clothing, dark and shadowy background colors, bruises and scratches visible on skin, sense of deep isolation, desperately seeking safety, care, and acceptance",
};

return Object.fromEntries(
await Promise.all(
Object.entries(prompts).map(async ([part, prompt]) => [
part,
(
await replicate.run(
"tencentarc/photomaker:ddfc2b08d209f9fa8c1eca692712918bd449f695dabb4a958da31802a9570fe4",
{
input: {
prompt: prompt,
num_steps: 40,
style_name: "Photographic (Default)",
input_image: inputUrl,
num_outputs: 1,
guidance_scale: 5,
negative_prompt:
"nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
style_strength_ratio: 20,
},
},
)
)[0],
]),
),
);
}

// FileRouter for your app, can contain multiple FileRoutes
export const fileRouter = {
// Define as many FileRoutes as you like, each with a unique routeSlug
Expand All @@ -25,9 +68,12 @@ export const fileRouter = {
console.log("Upload complete for userId:", metadata.userId);

console.log("file url", file.url);
const partImageUrls = await makePartImages(file.url);

console.log("Got image urls", partImageUrls);

// !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback
return { uploadedBy: metadata.userId, imageUrl: file.url };
return { uploadedBy: metadata.userId, imageUrl: file.url, partImageUrls: partImageUrls };
}),
} satisfies FileRouter;

Expand Down
32 changes: 32 additions & 0 deletions ifs.ai/app/audio-test/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { MicIcon, SendIcon } from "lucide-react";
import { useState } from "react";
import SpeechToText from "@/components/ui/speech-to-text";

export default function Page() {
const [message, setMessage] = useState("");
return (
<main className="flex min-h-svh flex-col px-24 py-10">
<div className="flex w-full flex-grow basis-0 space-x-4">
<div className="h-full w-4/5 flex-col">
<div className="flex h-full flex-col justify-between">
<SpeechToText
onTranscript={(transcript: string) => {
console.log(transcript);
setMessage(transcript);
}}
/>
<Input
value={message}
onChange={(e) => setMessage(e.target.value)}
placeholder="Type a message..."
className="flex-grow"
/>
</div>
</div>
</div>
</main>
);
}
Loading