Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[In Progress] [Feat]: Chat Component#1841

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes from1 commit
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
d5d9873
init chat component
iamfaranJun 30, 2025
d1d9b92
refactor component structure
iamfaranJun 30, 2025
0c132c1
install dependencies
iamfaranJun 30, 2025
4e7e540
add assistant-ui components
iamfaranJul 1, 2025
c541393
fix linter error
iamfaranJul 1, 2025
bf3810f
add thread
iamfaranJul 1, 2025
11c98fd
add properties for chat component
iamfaranJul 1, 2025
aec9485
add query / new hook from assisstant ui
iamfaranJul 2, 2025
b820f8e
use mock data
iamfaranJul 2, 2025
0dc85d4
add edit functionality
iamfaranJul 2, 2025
fd9dc77
fix message json issue
iamfaranJul 2, 2025
22934c6
Merge branch 'dev' of github.com:lowcoder-org/lowcoder into feat/chat…
iamfaranJul 2, 2025
52cdcf2
add threads logic
iamfaranJul 2, 2025
c619f89
add alaSql to chat component
iamfaranJul 2, 2025
f379cac
delete myruntime provider
iamfaranJul 2, 2025
e553d52
add storage support
iamfaranJul 3, 2025
dbd901c
add delete thread functionality
iamfaranJul 3, 2025
bf9f269
add rename thread ability
iamfaranJul 3, 2025
0205c72
[Feat]: Add chat component
iamfaranJul 4, 2025
be3b3ab
Merge branch 'dev' of github.com:lowcoder-org/lowcoder into feat/chat…
iamfaranJul 4, 2025
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
PrevPrevious commit
NextNext commit
fix message json issue
  • Loading branch information
@iamfaran
iamfaran committedJul 2, 2025
commitfd9dc7777d73c8cbbd2f0bbbf86a2aa3da99e857
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,14 +16,13 @@ interface MyMessage {

const generateId = () => Math.random().toString(36).substr(2, 9);

const callYourAPI = async (message: AppendMessage) => {
const callYourAPI = async (text: string) => {
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 1500));

// Simple responses
return {
content: "This is a mock response from your backend. You typed: " +
(typeof message.content === 'string' ? message.content : 'something')
content: "This is a mock response from your backend. You typed: " + text
};
};

Expand All@@ -41,11 +40,16 @@ export function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
});

const onNew = async (message: AppendMessage) => {
// Extract text from AppendMessage content array
if (message.content.length !== 1 || message.content[0]?.type !== "text") {
throw new Error("Only text content is supported");
}

// Add user message in your custom format
const userMessage: MyMessage = {
id: generateId(),
role: "user",
text:typeofmessage.content === 'string' ? message.content : JSON.stringify(message.content),
text: message.content[0].text,
timestamp: Date.now(),
};

Expand All@@ -54,7 +58,7 @@ export function MyRuntimeProvider({ children }: { children: React.ReactNode }) {

try {
// Call mock API
const response = await callYourAPI(message);
const response = await callYourAPI(userMessage.text);

const assistantMessage: MyMessage = {
id: generateId(),
Expand All@@ -81,6 +85,11 @@ export function MyRuntimeProvider({ children }: { children: React.ReactNode }) {

// Add onEdit functionality
const onEdit = async (message: AppendMessage) => {
// Extract text from AppendMessage content array
if (message.content.length !== 1 || message.content[0]?.type !== "text") {
throw new Error("Only text content is supported");
}

// Find the index where to insert the edited message
const index = myMessages.findIndex((m) => m.id === message.parentId) + 1;

Expand All@@ -91,7 +100,7 @@ export function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
const editedMessage: MyMessage = {
id: generateId(), // Always generate new ID for edited messages
role: "user",
text:typeofmessage.content === 'string' ? message.content : JSON.stringify(message.content),
text: message.content[0].text,
timestamp: Date.now(),
};
newMessages.push(editedMessage);
Expand All@@ -101,7 +110,7 @@ export function MyRuntimeProvider({ children }: { children: React.ReactNode }) {

try {
// Generate new response
const response = await callYourAPI(message);
const response = await callYourAPI(editedMessage.text);

const assistantMessage: MyMessage = {
id: generateId(),
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp