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

fix: whitespace-only properties cannot be editable #361

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ LITELLM_MODEL=gpt-4o-mini

# Extension: openai_chatgpt
# OpenAI API key
OPENAI_API_BASE=https://api.openai.com/v1
OPENAI_API_KEY=
OPENAI_MODEL=gpt-4o-mini

# OpenAI API key for realtime API
OPENAI_REALTIME_API_KEY=
Expand Down
28 changes: 14 additions & 14 deletions agents/property.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@
"extension_group": "chatgpt",
"name": "openai_chatgpt",
"property": {
"api_key": "$OPENAI_API_KEY",
"base_url": "",
"api_key": "${env:OPENAI_API_KEY}",
"base_url": "${env:OPENAI_API_BASE}",
"frequency_penalty": 0.9,
"greeting": "TEN Agent connected. How can I help you today?",
"max_memory_length": 10,
"max_tokens": 512,
"model": "gpt-4o-mini",
"model": "${env:OPENAI_MODEL}",
"prompt": "",
"proxy_url": "$OPENAI_PROXY_URL"
"proxy_url": "${env:OPENAI_PROXY_URL}"
},
"type": "extension"
},
Expand Down Expand Up @@ -258,10 +258,10 @@
"addon": "openai_chatgpt",
"name": "openai_chatgpt",
"property": {
"base_url": "",
"base_url": "${env:OPENAI_API_BASE}",
"api_key": "${env:OPENAI_API_KEY}",
"frequency_penalty": 0.9,
"model": "gpt-4o-mini",
"model": "${env:OPENAI_MODEL}",
"max_tokens": 512,
"prompt": "",
"proxy_url": "${env:OPENAI_PROXY_URL}",
Expand Down Expand Up @@ -457,10 +457,10 @@
"addon": "openai_chatgpt",
"name": "openai_chatgpt",
"property": {
"base_url": "",
"base_url": "${env:OPENAI_API_BASE}",
"api_key": "${env:OPENAI_API_KEY}",
"frequency_penalty": 0.9,
"model": "gpt-4o-mini",
"model": "${env:OPENAI_MODEL}",
"max_tokens": 512,
"prompt": "",
"proxy_url": "${env:OPENAI_PROXY_URL}",
Expand Down Expand Up @@ -662,10 +662,10 @@
"addon": "openai_chatgpt",
"name": "openai_chatgpt",
"property": {
"base_url": "",
"base_url": "${env:OPENAI_API_BASE}",
"api_key": "${env:OPENAI_API_KEY}",
"frequency_penalty": 0.9,
"model": "gpt-4o-mini",
"model": "${env:OPENAI_MODEL}",
"max_tokens": 512,
"prompt": "",
"proxy_url": "${env:OPENAI_PROXY_URL}",
Expand Down Expand Up @@ -1021,10 +1021,10 @@
"addon": "openai_chatgpt_python",
"name": "openai_chatgpt",
"property": {
"base_url": "",
"base_url": "${env:OPENAI_API_BASE}",
"api_key": "${env:OPENAI_API_KEY}",
"frequency_penalty": 0.9,
"model": "gpt-4o-mini",
"model": "${env:OPENAI_MODEL}",
"max_tokens": 512,
"prompt": "",
"proxy_url": "${env:OPENAI_PROXY_URL}",
Expand Down Expand Up @@ -1850,10 +1850,10 @@
"addon": "openai_chatgpt_python",
"name": "openai_chatgpt",
"property": {
"base_url": "",
"base_url": "${env:OPENAI_API_BASE}",
"api_key": "${env:OPENAI_API_KEY}",
"frequency_penalty": 0.9,
"model": "gpt-4o",
"model": "${env:OPENAI_MODEL}",
"max_tokens": 512,
"prompt": "",
"proxy_url": "${env:OPENAI_PROXY_URL}",
Expand Down
20 changes: 10 additions & 10 deletions playground/src/platform/pc/chat/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ const EditableTable: React.FC<EditableTableProps> = ({ initialData, onUpdate, me
const row = await form.validateFields();
const newData = [...dataSource];
const index = newData.findIndex((item) => key === item.key);

if (index > -1) {
const item = newData[index];
const valueType = metadata[key]?.type || 'string';
const updatedValue = row.value === '' ? null : convertToType(row.value, valueType); // Set to null if empty

newData.splice(index, 1, { ...item, value: updatedValue });
setDataSource(newData);
setEditingKey('');

// Notify the parent component of the update
const updatedData = Object.fromEntries(newData.map(({ key, value }) => [key, value]));
onUpdate(updatedData);
}
} catch (errInfo) {
console.log('Validation Failed:', errInfo);
}
};
};


// Toggle the checkbox for boolean values directly in the table cell
const handleCheckboxChange = (key: string, checked: boolean) => {
Expand Down Expand Up @@ -111,7 +111,7 @@ const EditableTable: React.FC<EditableTableProps> = ({ initialData, onUpdate, me
key: 'value',
render: (_, record: DataType) => {
const valueType = metadata[record.key]?.type || 'string';

// Always display the checkbox for boolean values
if (valueType === 'bool') {
return (
Expand All @@ -121,7 +121,7 @@ const EditableTable: React.FC<EditableTableProps> = ({ initialData, onUpdate, me
/>
);
}

// Inline editing for other types (string, number)
const editable = isEditing(record);
return editable ? (
Expand All @@ -137,13 +137,13 @@ const EditableTable: React.FC<EditableTableProps> = ({ initialData, onUpdate, me
</Form.Item>
) : (
<div onClick={() => edit(record)} style={{ cursor: 'pointer' }}>
{record.value !== null && record.value !== undefined && record.value !== ''
? record.value
{record.value != null && String(record.value).trim() !== ''
? String(record.value)
: <span style={{ color: 'gray' }}>Click to edit</span>}
</div>
);
},
},
},
];

return (
Expand Down