Skip to content

Commit 293a785

Browse files
committed
Add support for the Hugging Chat web interface
1 parent eff7b7e commit 293a785

9 files changed

Lines changed: 99 additions & 10 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Chatbot } from '../types/chatbot'
2+
import {
3+
add_apply_response_button,
4+
observe_for_responses
5+
} from '../utils/add-apply-response-button'
6+
import {
7+
InitializationError,
8+
report_initialization_error
9+
} from '../utils/report-initialization-error'
10+
11+
export const hugging_chat: Chatbot = {
12+
wait_until_ready: async () => {
13+
await new Promise((resolve) => setTimeout(resolve, 500))
14+
},
15+
inject_apply_response_button: (
16+
client_id: number,
17+
raw_instructions?: string,
18+
edit_format?: string
19+
) => {
20+
const add_buttons = (footer: Element) => {
21+
add_apply_response_button({
22+
client_id,
23+
raw_instructions,
24+
edit_format,
25+
footer,
26+
get_chat_turn: (f) => f.closest('div[data-message-role="assistant"]'),
27+
perform_copy: (f) => {
28+
const copy_button = f.querySelector(
29+
'button:nth-child(3)'
30+
) as HTMLElement
31+
if (!copy_button) {
32+
report_initialization_error({
33+
function_name: 'hugging_chat.perform_copy',
34+
log_message: 'Copy button not found',
35+
alert_message: InitializationError.UNABLE_TO_COPY_RESPONSE
36+
})
37+
return
38+
}
39+
copy_button.click()
40+
},
41+
insert_button: (f, b) => f.insertBefore(b, f.children[1])
42+
})
43+
}
44+
45+
observe_for_responses({
46+
chatbot_name: 'Hugging Chat',
47+
is_generating: () =>
48+
!!document.querySelector('button.stop-generating-btn'),
49+
footer_selector: 'div[data-message-role="assistant"] > div:nth-child(3)',
50+
add_buttons
51+
})
52+
}
53+
}

‎packages/browser/src/content-scripts/send-prompt-content-script/chatbots/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './deepseek'
66
export * from './gemini'
77
export * from './grok'
88
export * from './github-copilot'
9+
export * from './hugging-chat'
910
export * from './meta'
1011
export * from './mistral'
1112
export * from './open-webui'

‎packages/browser/src/content-scripts/send-prompt-content-script/send-prompt-content-script.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import {
1919
doubao,
2020
kimi,
2121
together,
22-
github_copilot
22+
github_copilot,
23+
hugging_chat
2324
} from './chatbots'
2425
import { perplexity } from './chatbots/perplexity'
2526
import { z_ai } from './chatbots/z-ai'
@@ -66,6 +67,9 @@ const is_qwen = current_url.startsWith(qwen_url)
6667
const yuanbao_url = 'https://yuanbao.tencent.com/chat'
6768
const is_yuanbao = current_url.startsWith(yuanbao_url)
6869

70+
const hugging_chat_url = 'https://huggingface.co/chat/'
71+
const is_hugging_chat = current_url.startsWith(hugging_chat_url)
72+
6973
const meta_url = 'https://www.meta.ai/'
7074
const is_meta = current_url.startsWith(meta_url)
7175

@@ -103,8 +107,8 @@ if (is_ai_studio) {
103107
chatbot = github_copilot
104108
} else if (is_claude) {
105109
chatbot = claude
106-
} else if (is_meta) {
107-
chatbot = meta
110+
} else if (is_hugging_chat) {
111+
chatbot = hugging_chat
108112
} else if (is_mistral) {
109113
chatbot = mistral
110114
} else if (is_open_webui) {
@@ -129,6 +133,8 @@ if (is_ai_studio) {
129133
chatbot = together
130134
} else if (is_z_ai) {
131135
chatbot = z_ai
136+
} else if (is_meta) {
137+
chatbot = meta
132138
}
133139

134140
export const get_textarea_element = () => {
@@ -145,7 +151,8 @@ export const get_textarea_element = () => {
145151
[doubao_url]: 'textarea',
146152
[together_url]: 'textarea',
147153
[z_ai_url]: 'textarea',
148-
[github_copilot_url]: 'textarea'
154+
[github_copilot_url]: 'textarea',
155+
[hugging_chat_url]: 'textarea'
149156
} as any
150157

151158
// Find the appropriate selector based on the URL without the hash

‎packages/browser/src/manifest.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Code Web Chat Connector",
55
"short_name": "CWC",
66
"description": "Connect your editor with free chatbots. Parse websites for context.",
7-
"version": "1.54.0",
7+
"version": "1.55.0",
88
"homepage_url": "https://github.com/robertpiosik/CodeWebChat",
99
"icons": {
1010
"16": "icons/icon-16.png",
@@ -34,6 +34,7 @@
3434
"https://gemini.google.com/u/*/app",
3535
"https://github.com/copilot",
3636
"https://grok.com/",
37+
"https://huggingface.co/chat/",
3738
"https://www.kimi.com/",
3839
"https://chat.mistral.ai/chat",
3940
"http://openwebui/",

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,20 @@ export const CHATBOTS = {
191191
'claude-opus-4': { label: 'Claude Opus 4' }
192192
}
193193
},
194+
'Hugging Chat': {
195+
url: 'https://huggingface.co/chat/',
196+
supports_custom_temperature: false,
197+
supports_custom_top_p: false,
198+
supports_system_instructions: false,
199+
supports_user_provided_model: false,
200+
supports_user_provided_port: false,
201+
supports_reasoning_effort: false,
202+
supports_thinking_budget: false,
203+
default_system_instructions: '',
204+
supported_options: {},
205+
default_top_p: 0,
206+
models: {}
207+
},
194208
Grok: {
195209
url: 'https://grok.com/',
196210
supports_custom_temperature: false,
Lines changed: 7 additions & 0 deletions
Loading

‎packages/ui/src/components/editor/common/Icon/Icon.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Doubao from '../../../../assets/icons/doubao.svg'
1414
import Enter from '../../../../assets/icons/enter.svg'
1515
import Gemini from '../../../../assets/icons/gemini.svg'
1616
import Grok from '../../../../assets/icons/grok.svg'
17+
import HuggingChat from '../../../../assets/icons/hugging-chat.svg'
1718
import Kimi from '../../../../assets/icons/kimi.svg'
1819
import Meta from '../../../../assets/icons/meta.svg'
1920
import Mistral from '../../../../assets/icons/mistral.svg'
@@ -38,13 +39,14 @@ export namespace Icon {
3839
| 'CODE_WEB_CHAT_TEXT'
3940
| 'COMMAND'
4041
| 'COPILOT'
41-
| 'GITHUB_COPILOT'
4242
| 'DEEPSEEK'
4343
| 'DISCORD'
4444
| 'DOUBAO'
4545
| 'ENTER'
4646
| 'GEMINI'
47+
| 'GITHUB_COPILOT'
4748
| 'GROK'
49+
| 'HUGGING_CHAT'
4850
| 'KIMI'
4951
| 'META'
5052
| 'MISTRAL'
@@ -94,9 +96,6 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
9496
case 'COPILOT':
9597
icon = <Copilot />
9698
break
97-
case 'GITHUB_COPILOT':
98-
icon = <GithubCopilot />
99-
break
10099
case 'DEEPSEEK':
101100
icon = <DeepSeek />
102101
break
@@ -112,9 +111,15 @@ export const Icon: React.FC<Icon.Props> = ({ variant }) => {
112111
case 'GEMINI':
113112
icon = <Gemini />
114113
break
114+
case 'GITHUB_COPILOT':
115+
icon = <GithubCopilot />
116+
break
115117
case 'GROK':
116118
icon = <Grok />
117119
break
120+
case 'HUGGING_CHAT':
121+
icon = <HuggingChat />
122+
break
118123
case 'KIMI':
119124
icon = <Kimi />
120125
break

‎packages/ui/src/components/editor/panel/Presets/Presets.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
1717
Gemini: 'GEMINI',
1818
'GitHub Copilot': 'GITHUB_COPILOT',
1919
Grok: 'GROK',
20+
'Hugging Chat': 'HUGGING_CHAT',
2021
Kimi: 'KIMI',
2122
Mistral: 'MISTRAL',
2223
// Meta: 'META',

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "No-cost AI coding in free chatbots (CWC)",
5-
"version": "1.450.0",
5+
"version": "1.451.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

0 commit comments

Comments
 (0)