Skip to content

Commit ee60de4

Browse files
authored
Merge branch 'main' into dev/more_icons
2 parents 3a28d01 + 6ccea52 commit ee60de4

File tree

5 files changed

+32
-18
lines changed

5 files changed

+32
-18
lines changed

.env.azure-example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OPENAI_API_KEY=XXXX
22
OPENAI_API_TYPE=azure
3-
OPENAI_BASE_URL=https://your-resource-name.openai.azure.com
3+
OPENAI_API_BASE=https://your-resource-name.openai.azure.com
44
OPENAI_API_VERSION=2023-03-15-preview
55
# OPENAI_EXTRA_HEADERS={"key": "value"}
66
AZURE_OPENAI_DEPLOYMENTS=[{"displayName": "GPT-3.5", "name": "your-gpt-3.5-deployment"}, {"displayName": "GPT-4", "name": "your-gpt-4-deployment"}]

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OPENAI_API_KEY=sk-XXXX
22
OPENAI_API_TYPE=open_ai
3-
OPENAI_BASE_URL=https://api.openai.com/v1
3+
OPENAI_API_BASE=https://api.openai.com/v1
44
OPENAI_API_VERSION=2023-03-15-preview
55
# OPENAI_EXTRA_HEADERS={"key": "value"}
66
OPENAI_MODELS=[{"displayName": "GPT-3.5", "name": "gpt-3.5-turbo"}, {"displayName": "GPT-4", "name": "gpt-4"}]

frontend/src/App.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ function App() {
117117
}),
118118
});
119119

120-
121-
122120
const data = await response.json();
123121
const code = data.code;
124122

@@ -129,8 +127,12 @@ function App() {
129127
return;
130128
}
131129

132-
submitCode(code);
133-
setWaitingForSystem(WaitingStates.RunningCode);
130+
if (!!code) {
131+
submitCode(code);
132+
setWaitingForSystem(WaitingStates.RunningCode);
133+
} else {
134+
setWaitingForSystem(WaitingStates.Idle);
135+
}
134136
} catch (error) {
135137
console.error(
136138
"There has been a problem with your fetch operation:",

frontend/src/components/Chat.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,29 @@ function Message(props: {
4646
</div>
4747
) : (
4848
isMarkdown(text) ?
49-
<ReactMarkdown
50-
children={text}
51-
remarkPlugins={[remarkGfm]}
52-
/> :
49+
<ReactMarkdown
50+
children={text}
51+
remarkPlugins={[remarkGfm]}
52+
components={{
53+
code({node, inline, className, children, style, ...props}) {
54+
const match = /language-(\w+)/.exec(className || '')
55+
return !inline ? (
56+
<SyntaxHighlighter
57+
{...props}
58+
children={String(children).replace(/\n$/, '')}
59+
wrapLongLines={true}
60+
language={match ? match[1] : "python"}
61+
PreTag="div"
62+
/>
63+
) : (
64+
<code {...props} className={className}>
65+
{children}
66+
</code>
67+
)
68+
}
69+
}}
70+
/>
71+
:
5372
<div className="cell-output" dangerouslySetInnerHTML={{ __html: text }}></div>
5473
))}
5574

gpt_code_ui/webapp/main.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,7 @@ def extract_code(text):
171171
if single_match:
172172
return single_match.group(1).strip()
173173

174-
def extract_non_code(text):
175-
# Replace triple backtick blocks
176-
text = re.sub(r'```(?:\w+\n)?(.+?)```', '', text, flags=re.DOTALL)
177-
# Replace single backtick blocks
178-
text = re.sub(r'`(.+?)`', '', text, flags=re.DOTALL)
179-
return text.strip()
180-
181-
return extract_code(content), extract_non_code(content), 200
174+
return extract_code(content), content.strip(), 200
182175

183176
# We know this Flask app is for local use. So we can disable the verbose Werkzeug logger
184177
log = logging.getLogger('werkzeug')

0 commit comments

Comments
 (0)