mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[pycharm] PY-63670 updates in the HF community module for HF model choice MVP
GitOrigin-RevId: 598962bb98a7435320cd224ca9c8fcdcabe897fd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6e67ff4544
commit
0646bef0d4
@@ -7,7 +7,7 @@ python.hugging.face.base.url=https://huggingface.co
|
||||
python.hugging.face.updated.suffix= Updated {0}
|
||||
python.hugging.face.open.on.link.text=Open on Hugging Face
|
||||
|
||||
python.hugging.face.placeholder.gated.model=<font color='gray'>Sorry, this {0} is gated.<br>Please visit the [HuggingFace website]({1}) <br>for more details about the {2} card.</font>
|
||||
python.hugging.face.placeholder.gated.model=Sorry, this {0} is gated.<br>Please visit the [HuggingFace website]({1}) <br>for more details about the {2} card.
|
||||
python.hugging.face.placeholder.no.readme=This model has no description available. For more details, please follow the [link]({0})
|
||||
python.hugging.face.placeholder.trimmed=*Please find the rest of the {0} card [here]({1})*
|
||||
python.hugging.face.placeholder.no.internet=Failed to fetch data for {0}. Please check your internet connection.
|
||||
|
||||
+3
-4
@@ -5,9 +5,8 @@ import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
enum class HuggingFaceModelSortKey(val value: String, val displayName: String) {
|
||||
AUTHOR("author", "Author"),
|
||||
CREATED_AT("createdAt", "Created At"),
|
||||
LAST_MODIFIED("lastModified", "Last Modified"),
|
||||
DOWNLOADS("downloads", "Downloads"),
|
||||
LIKES("likes", "Likes");
|
||||
LIKES("likes", "Likes"),
|
||||
CREATED_AT("createdAt", "Created At"),
|
||||
LAST_MODIFIED("lastModified", "Last Modified");
|
||||
}
|
||||
|
||||
+6
-1
@@ -37,6 +37,12 @@ abstract class HuggingFaceCache(private val maxSize: Int) : PersistentStateCompo
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun saveEntity(entityData: HuggingFaceEntityBasicApiData) {
|
||||
cacheMap[entityData.itemId] = entityData
|
||||
nameSet.add(entityData.itemId)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun isInCache(entityId: String): Boolean {
|
||||
if (hotCache.containsKey(entityId)) return true
|
||||
@@ -67,7 +73,6 @@ abstract class HuggingFaceCache(private val maxSize: Int) : PersistentStateCompo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@State(
|
||||
name = "HuggingFaceModelsCache",
|
||||
storages = [Storage("huggingFaceModelsCache.xml")]
|
||||
|
||||
+12
-12
@@ -11,6 +11,7 @@ import com.intellij.python.community.impl.huggingFace.HuggingFaceEntityKind
|
||||
import com.intellij.python.community.impl.huggingFace.api.HuggingFaceEntityBasicApiData
|
||||
import com.intellij.python.community.impl.huggingFace.api.HuggingFaceURLProvider
|
||||
import com.intellij.python.community.impl.huggingFace.service.PyHuggingFaceBundle
|
||||
import com.jetbrains.python.PythonLanguage
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
|
||||
@@ -29,7 +30,7 @@ class HuggingFaceHtmlBuilder(
|
||||
} else {
|
||||
generateCardHeader(modelDataApiContent)
|
||||
}
|
||||
@NlsSafe val convertedHtml = readAction { DocMarkdownToHtmlConverter.convert(project, modelCardContent) }
|
||||
@NlsSafe val convertedHtml = readAction { DocMarkdownToHtmlConverter.convert(project, modelCardContent, PythonLanguage.INSTANCE) }
|
||||
|
||||
val wrappedBodyContent = HtmlChunk.div()
|
||||
.setClass(DocumentationMarkup.CLASS_CONTENT)
|
||||
@@ -58,8 +59,6 @@ class HuggingFaceHtmlBuilder(
|
||||
listOf(HtmlChunk.text(PyHuggingFaceBundle.message("python.hugging.face.dataset")), HtmlChunk.nbsp(2))
|
||||
}
|
||||
|
||||
|
||||
|
||||
val modelInfoRow = DocumentationMarkup.GRAYED_ELEMENT
|
||||
.children(
|
||||
*conditionalChunks.toTypedArray(),
|
||||
@@ -80,21 +79,22 @@ class HuggingFaceHtmlBuilder(
|
||||
.child(HtmlChunk.text(PyHuggingFaceBundle.getMessage("python.hugging.face.open.on.link.text")))
|
||||
.wrapWith("p")
|
||||
|
||||
val headerContainer = HtmlChunk.div()
|
||||
.setClass(DocumentationMarkup.CLASS_DEFINITION)
|
||||
.children(
|
||||
modelNameWithIconRow,
|
||||
modelInfoRow,
|
||||
linkRow,
|
||||
)
|
||||
val headerContainer = HtmlChunk.div()
|
||||
.setClass(DocumentationMarkup.CLASS_DEFINITION)
|
||||
.children(
|
||||
modelNameWithIconRow,
|
||||
modelInfoRow,
|
||||
linkRow,
|
||||
)
|
||||
|
||||
return headerContainer
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val NBHP = "‑"
|
||||
private val DOWNLOADS_ICON = HtmlChunk.tag("icon")
|
||||
.attr("src", "AllIcons.Actions.Download")
|
||||
.attr("src", "AllIcons.Plugins.Downloads")
|
||||
private val LIKES_ICON = HtmlChunk.tag("icon")
|
||||
.attr(".src", "AllIcons.Toolwindows.ToolWindowFavorites")
|
||||
.attr(".src", "AllIcons.Plugins.Rating")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user